TF-2599 Fix notification flood

Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
dab246
2024-02-22 15:49:01 +07:00
committed by Dat H. Pham
parent 07042bfb45
commit a90e36c6b3
8 changed files with 124 additions and 87 deletions
@@ -1,18 +1,20 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:jmap_dart_client/jmap/core/user_name.dart';
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
class GetEmailChangesToRemoveNotificationLoading extends UIState {}
class GetEmailChangesToRemoveNotificationSuccess extends UIState {
final UserName userName;
final List<EmailId> emailIds;
GetEmailChangesToRemoveNotificationSuccess(this.emailIds);
GetEmailChangesToRemoveNotificationSuccess(this.userName, this.emailIds);
@override
List<Object> get props => [emailIds];
List<Object> get props => [userName, emailIds];
}
class GetEmailChangesToRemoveNotificationFailure extends FeatureFailure {
@@ -1,6 +1,7 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:jmap_dart_client/jmap/core/user_name.dart';
import 'package:model/mailbox/presentation_mailbox.dart';
class GetMailboxesNotPutNotificationsLoading extends UIState {}
@@ -8,14 +9,17 @@ class GetMailboxesNotPutNotificationsLoading extends UIState {}
class GetMailboxesNotPutNotificationsSuccess extends UIState {
final List<PresentationMailbox> mailboxes;
final UserName userName;
GetMailboxesNotPutNotificationsSuccess(this.mailboxes);
GetMailboxesNotPutNotificationsSuccess(this.mailboxes, this.userName);
@override
List<Object> get props => [mailboxes];
List<Object> get props => [mailboxes, userName];
}
class GetMailboxesNotPutNotificationsFailure extends FeatureFailure {
GetMailboxesNotPutNotificationsFailure(exception) : super(exception: exception);
final UserName userName;
GetMailboxesNotPutNotificationsFailure(exception, this.userName) : super(exception: exception);
}
@@ -38,7 +38,7 @@ class GetEmailChangesToRemoveNotificationInteractor {
currentState,
propertiesCreated: propertiesCreated,
propertiesUpdated: propertiesUpdated);
yield Right<Failure, Success>(GetEmailChangesToRemoveNotificationSuccess(emailIds));
yield Right<Failure, Success>(GetEmailChangesToRemoveNotificationSuccess(session.username, emailIds));
} else {
yield Left<Failure, Success>(GetEmailChangesToRemoveNotificationFailure(NotFoundEmailStateException()));
}
@@ -15,9 +15,9 @@ class GetMailboxesNotPutNotificationsInteractor {
try {
yield Right<Failure, Success>(GetMailboxesNotPutNotificationsLoading());
final mailboxes = await _fcmRepository.getMailboxesNotPutNotifications(session, accountId);
yield Right<Failure, Success>(GetMailboxesNotPutNotificationsSuccess(mailboxes));
yield Right<Failure, Success>(GetMailboxesNotPutNotificationsSuccess(mailboxes, session.username));
} catch (e) {
yield Left<Failure, Success>(GetMailboxesNotPutNotificationsFailure(e));
yield Left<Failure, Success>(GetMailboxesNotPutNotificationsFailure(e, session.username));
}
}
}