TF-437 Handle Mailbox/changes in background/terminated
This commit is contained in:
+9
@@ -68,8 +68,10 @@ import 'package:tmail_ui_user/features/manage_account/presentation/model/account
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_email_state_to_refresh_state.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_mailbox_state_to_refresh_state.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/controller/fcm_controller.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/services/fcm_service.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
@@ -118,6 +120,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
UpdateVacationInteractor? _updateVacationInteractor;
|
||||
GetEmailStateToRefreshInteractor? _getEmailStateToRefreshInteractor;
|
||||
DeleteEmailStateToRefreshInteractor? _deleteEmailStateToRefreshInteractor;
|
||||
GetMailboxStateToRefreshInteractor? _getMailboxStateToRefreshInteractor;
|
||||
|
||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final selectedMailbox = Rxn<PresentationMailbox>();
|
||||
@@ -231,6 +234,8 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
} else if (success is GetEmailStateToRefreshSuccess) {
|
||||
dispatchAction(RefreshChangeEmailAction(success.storedState));
|
||||
_deleteEmailStateToRefreshAction();
|
||||
} else if (success is GetMailboxStateToRefreshSuccess) {
|
||||
dispatchAction(RefreshChangeMailboxAction(success.storedState));
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -1287,12 +1292,16 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
log('MailboxDashBoardController::_handleRefreshActionWhenBackToApp():');
|
||||
try {
|
||||
_getEmailStateToRefreshInteractor = getBinding<GetEmailStateToRefreshInteractor>();
|
||||
_getMailboxStateToRefreshInteractor = getBinding<GetMailboxStateToRefreshInteractor>();
|
||||
} catch (e) {
|
||||
logError('MailboxDashBoardController::_handleRefreshActionWhenBackToApp(): $e');
|
||||
}
|
||||
if (_getEmailStateToRefreshInteractor != null) {
|
||||
consumeState(_getEmailStateToRefreshInteractor!.execute());
|
||||
}
|
||||
if (_getMailboxStateToRefreshInteractor != null) {
|
||||
consumeState(_getMailboxStateToRefreshInteractor!.execute());
|
||||
}
|
||||
}
|
||||
|
||||
void _deleteEmailStateToRefreshAction() {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
|
||||
class GetMailboxStateToRefreshLoading extends UIState {}
|
||||
|
||||
class GetMailboxStateToRefreshSuccess extends UIState {
|
||||
|
||||
final jmap.State storedState;
|
||||
|
||||
GetMailboxStateToRefreshSuccess(this.storedState);
|
||||
|
||||
@override
|
||||
List<Object> get props => [storedState];
|
||||
}
|
||||
|
||||
class GetMailboxStateToRefreshFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
GetMailboxStateToRefreshFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/type_name.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_mailbox_state_to_refresh_state.dart';
|
||||
|
||||
class GetMailboxStateToRefreshInteractor {
|
||||
final FCMRepository _fcmRepository;
|
||||
|
||||
GetMailboxStateToRefreshInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetMailboxStateToRefreshLoading());
|
||||
final storedState = await _fcmRepository.getStateToRefresh(TypeName.mailboxType);
|
||||
yield Right<Failure, Success>(GetMailboxStateToRefreshSuccess(storedState));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetMailboxStateToRefreshFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_dev
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_changes_to_push_notification_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_firebase_subscription_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_fcm_token_cache_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_mailbox_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_stored_email_delivery_state_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/register_new_token_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_device_id_interactor.dart';
|
||||
@@ -64,6 +66,7 @@ class FcmInteractorBindings extends InteractorsBindings {
|
||||
Get.lazyPut(() => RegisterNewTokenInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetDeviceIdInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => StoreMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user