diff --git a/lib/features/caching/caching_manager.dart b/lib/features/caching/caching_manager.dart index f06dde63c..117b46ab9 100644 --- a/lib/features/caching/caching_manager.dart +++ b/lib/features/caching/caching_manager.dart @@ -4,6 +4,7 @@ import 'package:tmail_ui_user/features/caching/email_cache_client.dart'; import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart'; import 'package:tmail_ui_user/features/caching/recent_search_cache_client.dart'; import 'package:tmail_ui_user/features/caching/state_cache_client.dart'; +import 'package:tmail_ui_user/features/caching/subscription_cache_client.dart'; import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart'; import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart'; @@ -16,6 +17,7 @@ class CachingManager { final RecentSearchCacheClient _recentSearchCacheClient; final AccountCacheClient _accountCacheClient; final FCMCacheManager _fcmCacheManager; + final FCMSubscriptionCacheClient _fcmSubscriptionCacheClient; CachingManager( this._mailboxCacheClient, @@ -24,6 +26,7 @@ class CachingManager { this._recentSearchCacheClient, this._accountCacheClient, this._fcmCacheManager, + this._fcmSubscriptionCacheClient, ); Future clearAll() async { @@ -33,6 +36,7 @@ class CachingManager { _emailCacheClient.clearAllData(), _recentSearchCacheClient.clearAllData(), _accountCacheClient.clearAllData(), + _fcmSubscriptionCacheClient.clearAllData(), _fcmCacheManager.clearAllStateToRefresh() ]); } diff --git a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart index 09d41daca..b459edc43 100644 --- a/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart +++ b/lib/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart @@ -1400,13 +1400,7 @@ class MailboxDashBoardController extends ReloadableController { void popAllRouteIfHave() { Get.until((route) => Get.currentRoute == AppRoutes.dashboard); } - - @override - void logoutAction() { - popBack(); - super.logoutAction(); - } - + @override void onClose() { _emailReceiveManager.closeEmailReceiveManagerStream(); diff --git a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart index fa0e47237..b5708c610 100644 --- a/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart +++ b/lib/features/mailbox_dashboard/presentation/mailbox_dashboard_view_web.dart @@ -319,7 +319,8 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView { controller.openPopupMenuAction(context, position, popupMenuUserSettingActionTile(context, controller.userProfile.value, onLogoutAction: () { - controller.logout(controller.sessionCurrent, controller.accountId.value); + popBack(); + controller.logout(controller.sessionCurrent, controller.accountId.value); }, onSettingAction: () { popBack(); diff --git a/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart b/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart index 7fa3fa7d6..20b2a1d31 100644 --- a/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart +++ b/lib/features/manage_account/presentation/manage_account_dashboard_controller.dart @@ -299,10 +299,4 @@ class ManageAccountDashBoardController extends ReloadableController { dashboardSettingAction.value = newAction; } } - - @override - void logoutAction() { - popBack(); - super.logoutAction(); - } } \ No newline at end of file diff --git a/lib/features/manage_account/presentation/manage_account_dashboard_view.dart b/lib/features/manage_account/presentation/manage_account_dashboard_view.dart index cb43e1651..c29cbebaf 100644 --- a/lib/features/manage_account/presentation/manage_account_dashboard_view.dart +++ b/lib/features/manage_account/presentation/manage_account_dashboard_view.dart @@ -142,7 +142,8 @@ class ManageAccountDashBoardView extends GetWidget(); - final manageAccountMenuController = Get.find(); - void selectSettings(AccountMenuItem accountMenuItem) { log('SettingsController::selectSettings(): $accountMenuItem'); diff --git a/lib/features/manage_account/presentation/menu/settings/settings_first_level_view.dart b/lib/features/manage_account/presentation/menu/settings/settings_first_level_view.dart index 9d62ce7af..6f6539cb5 100644 --- a/lib/features/manage_account/presentation/menu/settings/settings_first_level_view.dart +++ b/lib/features/manage_account/presentation/menu/settings/settings_first_level_view.dart @@ -119,7 +119,9 @@ class SettingsFirstLevelView extends GetWidget { SettingFirstLevelTileBuilder( AppLocalizations.of(context).sign_out, _imagePaths.icSignOut, - controller.manageAccountMenuController.logout, + () => controller.manageAccountDashboardController.logout( + controller.manageAccountDashboardController.sessionCurrent.value, + controller.manageAccountDashboardController.accountId.value) ), ]), ); diff --git a/lib/features/push_notification/data/datasource_impl/fcm_subscriptions_impl.dart b/lib/features/push_notification/data/datasource_impl/fcm_subscriptions_impl.dart deleted file mode 100644 index 4ae4b5c79..000000000 --- a/lib/features/push_notification/data/datasource_impl/fcm_subscriptions_impl.dart +++ /dev/null @@ -1,62 +0,0 @@ -import 'package:fcm/model/firebase_subscription.dart'; -import 'package:fcm/model/type_name.dart'; -import 'package:jmap_dart_client/jmap/core/state.dart' as jmap; -import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart'; -import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart'; -import 'package:tmail_ui_user/features/push_notification/data/model/fcm_subscription.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart'; -import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; - -class CacheFCMDatasourceImpl extends FCMDatasource { - - final FCMCacheManager _firebaseCacheManager; - final ExceptionThrower _exceptionThrower; - - CacheFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower); - - @override - Future storeStateToRefresh(TypeName typeName, jmap.State newState) { - return Future.sync(() async { - return await _firebaseCacheManager.storeStateToRefresh(typeName, newState); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future getStateToRefresh(TypeName typeName) { - return Future.sync(() async { - return await _firebaseCacheManager.getStateToRefresh(typeName); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future deleteStateToRefresh(TypeName typeName) { - return Future.sync(() async { - return await _firebaseCacheManager.deleteStateToRefresh(typeName); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future getFirebaseSubscriptionByDeviceId(String deviceId) { - throw UnimplementedError(); - } - - @override - Future registerNewToken(RegisterNewTokenRequest newTokenRequest) { - throw UnimplementedError(); - } - - @override - Future storeSubscription(FCMSubscriptionCache fcmSubscriptionCache) { - return Future.sync(() async { - return await _firebaseCacheManager.storeSubscription(fcmSubscriptionCache); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } -} \ No newline at end of file diff --git a/lib/features/push_notification/data/datasource_impl/hive_fcm_datasource_impl.dart b/lib/features/push_notification/data/datasource_impl/hive_fcm_datasource_impl.dart deleted file mode 100644 index 60463226d..000000000 --- a/lib/features/push_notification/data/datasource_impl/hive_fcm_datasource_impl.dart +++ /dev/null @@ -1,70 +0,0 @@ -import 'package:fcm/model/firebase_subscription.dart'; -import 'package:fcm/model/type_name.dart'; -import 'package:jmap_dart_client/jmap/core/state.dart' as jmap; -import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart'; -import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart'; -import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart'; - -class HiveFCMDatasourceImpl extends FCMDatasource { - - final FCMCacheManager _firebaseCacheManager; - final ExceptionThrower _exceptionThrower; - - HiveFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower); - - @override - Future storeStateToRefresh(TypeName typeName, jmap.State newState) { - return Future.sync(() async { - return await _firebaseCacheManager.storeStateToRefresh(typeName, newState); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future getStateToRefresh(TypeName typeName) { - return Future.sync(() async { - return await _firebaseCacheManager.getStateToRefresh(typeName); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future deleteStateToRefresh(TypeName typeName) { - return Future.sync(() async { - return await _firebaseCacheManager.deleteStateToRefresh(typeName); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future storeDeviceId(String deviceId) { - return Future.sync(() async { - return await _firebaseCacheManager.storeDeviceId(deviceId); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } - - @override - Future getFirebaseSubscriptionByDeviceId(String deviceId) { - throw UnimplementedError(); - } - - @override - Future registerNewToken(RegisterNewTokenRequest newTokenRequest) { - throw UnimplementedError(); - } - - @override - Future getDeviceId() { - return Future.sync(() async { - return await _firebaseCacheManager.getDeviceId(); - }).catchError((error) { - _exceptionThrower.throwException(error); - }); - } -} \ No newline at end of file diff --git a/lib/features/push_notification/data/local/fcm_cache_manager.dart b/lib/features/push_notification/data/local/fcm_cache_manager.dart index 06f4291d7..49ef77d65 100644 --- a/lib/features/push_notification/data/local/fcm_cache_manager.dart +++ b/lib/features/push_notification/data/local/fcm_cache_manager.dart @@ -41,7 +41,7 @@ class FCMCacheManager { return await Future.wait([ _sharedPreferences.remove(TypeName.emailType.value), _sharedPreferences.remove(TypeName.mailboxType.value), - _sharedPreferences.remove(TypeName.emailDelivery.value) + _sharedPreferences.remove(TypeName.emailDelivery.value), ]).then((listResult) => listResult.every((result) => result)); } diff --git a/lib/features/push_notification/data/network/fcm_api.dart b/lib/features/push_notification/data/network/fcm_api.dart index 280eaa9ff..3a78df6ca 100644 --- a/lib/features/push_notification/data/network/fcm_api.dart +++ b/lib/features/push_notification/data/network/fcm_api.dart @@ -70,7 +70,7 @@ class FcmApi { final processingInvocation = ProcessingInvocation(); final requestBuilder = JmapRequestBuilder(_httpClient, processingInvocation); - final firebaseSubscriptionSetMethod = FirebaseSubscriptionSetMethod(); + final firebaseSubscriptionSetMethod = FirebaseSubscriptionSetMethod()..addDestroy({Id(subscriptionId)}); final firebaseSubscriptionSetInvocation = requestBuilder.invocation(firebaseSubscriptionSetMethod); final response = await (requestBuilder ..usings({ diff --git a/lib/features/push_notification/domain/state/get_device_id_state.dart b/lib/features/push_notification/domain/state/get_device_id_state.dart deleted file mode 100644 index 45b694ce4..000000000 --- a/lib/features/push_notification/domain/state/get_device_id_state.dart +++ /dev/null @@ -1,24 +0,0 @@ - -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; - -class GetDeviceIdLoading extends UIState {} - -class GetDeviceIdSuccess extends UIState { - - final String deviceId; - - GetDeviceIdSuccess(this.deviceId); - - @override - List get props => [deviceId]; -} - -class GetDeviceIdFailure extends FeatureFailure { - final dynamic exception; - - GetDeviceIdFailure(this.exception); - - @override - List get props => [exception]; -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/state/store_device_id_state.dart b/lib/features/push_notification/domain/state/store_device_id_state.dart deleted file mode 100644 index 35c4c8d7f..000000000 --- a/lib/features/push_notification/domain/state/store_device_id_state.dart +++ /dev/null @@ -1,22 +0,0 @@ - -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; - -class StoreDeviceIdLoading extends UIState {} - -class StoreDeviceIdSuccess extends UIState { - - StoreDeviceIdSuccess(); - - @override - List get props => []; -} - -class StoreDeviceIdFailure extends FeatureFailure { - final dynamic exception; - - StoreDeviceIdFailure(this.exception); - - @override - List get props => [exception]; -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/usecases/get_device_id_interactor.dart b/lib/features/push_notification/domain/usecases/get_device_id_interactor.dart deleted file mode 100644 index 5c3603136..000000000 --- a/lib/features/push_notification/domain/usecases/get_device_id_interactor.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:dartz/dartz.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_device_id_state.dart'; - -class GetDeviceIdInteractor { - final FCMRepository _fcmRepository; - - GetDeviceIdInteractor(this._fcmRepository); - - Stream> execute() async* { - try { - yield Right(GetDeviceIdLoading()); - final deviceId = await _fcmRepository.getDeviceId(); - yield Right(GetDeviceIdSuccess(deviceId)); - } catch (e) { - yield Left(GetDeviceIdFailure(e)); - } - } -} \ No newline at end of file diff --git a/lib/features/push_notification/domain/usecases/store_device_id_interactor.dart b/lib/features/push_notification/domain/usecases/store_device_id_interactor.dart deleted file mode 100644 index cc53a4d99..000000000 --- a/lib/features/push_notification/domain/usecases/store_device_id_interactor.dart +++ /dev/null @@ -1,21 +0,0 @@ -import 'package:core/presentation/state/failure.dart'; -import 'package:core/presentation/state/success.dart'; -import 'package:dartz/dartz.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart'; -import 'package:tmail_ui_user/features/push_notification/domain/state/store_device_id_state.dart'; - -class StoreDeviceIdInteractor { - final FCMRepository _fcmRepository; - - StoreDeviceIdInteractor(this._fcmRepository); - - Stream> execute(String deviceId) async* { - try { - yield Right(StoreDeviceIdLoading()); - await _fcmRepository.storeDeviceId(deviceId); - yield Right(StoreDeviceIdSuccess()); - } catch (e) { - yield Left(StoreDeviceIdFailure(e)); - } - } -} \ No newline at end of file diff --git a/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart b/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart index 91af57fd3..a131bd6cc 100644 --- a/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart +++ b/lib/features/push_notification/presentation/bindings/fcm_interactor_bindings.dart @@ -9,6 +9,7 @@ import 'package:tmail_ui_user/features/push_notification/data/network/fcm_api.da import 'package:tmail_ui_user/features/push_notification/data/repository/fcm_repository_impl.dart'; import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.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/destroy_subscription_interactor.dart'; 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_fcm_subscription_local_interactor.dart'; @@ -66,6 +67,7 @@ class FcmInteractorBindings extends InteractorsBindings { Get.lazyPut(() => GetMailboxStateToRefreshInteractor(Get.find())); Get.lazyPut(() => StoreSubscriptionInteractor(Get.find())); Get.lazyPut(() => GetFCMSubscriptionLocalInteractor(Get.find())); + Get.lazyPut(() => DestroySubscriptionInteractor(Get.find())); } @override diff --git a/lib/main/bindings/local/local_bindings.dart b/lib/main/bindings/local/local_bindings.dart index 94a366f49..853939ee9 100644 --- a/lib/main/bindings/local/local_bindings.dart +++ b/lib/main/bindings/local/local_bindings.dart @@ -65,7 +65,8 @@ class LocalBindings extends Bindings { Get.find(), Get.find(), Get.find(), - Get.find() + Get.find(), + Get.find(), )); }