TF-1600 Implement GetMailboxesNotPutNotificationsInteractor
(cherry picked from commit ba849b288e4e943648c35bf6a494eaa804b049b6)
This commit is contained in:
@@ -3,6 +3,7 @@ import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/model/fcm_subscription.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||
@@ -34,4 +35,6 @@ abstract class FCMRepository {
|
||||
Future<FCMSubscription> getSubscription();
|
||||
|
||||
Future<bool> destroySubscription(String subscriptionId);
|
||||
|
||||
Future<List<PresentationMailbox>> getMailboxesNotPutNotifications(Session session, AccountId accountId);
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||
|
||||
class GetMailboxesNotPutNotificationsLoading extends UIState {}
|
||||
|
||||
class GetMailboxesNotPutNotificationsSuccess extends UIState {
|
||||
|
||||
final List<PresentationMailbox> mailboxes;
|
||||
|
||||
GetMailboxesNotPutNotificationsSuccess(this.mailboxes);
|
||||
|
||||
@override
|
||||
List<Object> get props => [mailboxes];
|
||||
}
|
||||
|
||||
class GetMailboxesNotPutNotificationsFailure extends FeatureFailure {
|
||||
|
||||
GetMailboxesNotPutNotificationsFailure(exception) : super(exception: exception);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [exception];
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailboxes_not_put_notifications_state.dart';
|
||||
|
||||
class GetMailboxesNotPutNotificationsInteractor {
|
||||
final FCMRepository _fcmRepository;
|
||||
|
||||
GetMailboxesNotPutNotificationsInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(Session session, AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetMailboxesNotPutNotificationsLoading());
|
||||
final mailboxes = await _fcmRepository.getMailboxesNotPutNotifications(session, accountId);
|
||||
yield Right<Failure, Success>(GetMailboxesNotPutNotificationsSuccess(mailboxes));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetMailboxesNotPutNotificationsFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user