TF-1289: [Presentation] Implement GetSubscription in presentation and reloadable
This commit is contained in:
@@ -24,6 +24,8 @@ import 'package:tmail_ui_user/features/manage_account/data/local/language_cache_
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/state/log_out_oidc_state.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/vacation/vacation_interactors_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_fcm_subscription_local.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_fcm_subscription_local_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/services/fcm_receiver.dart';
|
||||
import 'package:tmail_ui_user/features/session/domain/state/get_session_state.dart';
|
||||
import 'package:tmail_ui_user/features/session/domain/usecases/get_session_interactor.dart';
|
||||
@@ -46,6 +48,8 @@ abstract class ReloadableController extends BaseController {
|
||||
final GetAuthenticatedAccountInteractor _getAuthenticatedAccountInteractor;
|
||||
final _fcmReceiver = FcmReceiver.instance;
|
||||
|
||||
GetFCMSubscriptionLocalInteractor? _getSubscriptionLocalInteractor;
|
||||
|
||||
ReloadableController(
|
||||
this._logoutOidcInteractor,
|
||||
this._deleteAuthorityOidcInteractor,
|
||||
@@ -67,7 +71,9 @@ abstract class ReloadableController extends BaseController {
|
||||
_goToLogin(arguments: LoginArguments(LoginFormType.ssoForm));
|
||||
} else if (failure is GetAuthenticatedAccountFailure || failure is NoAuthenticatedAccountFailure) {
|
||||
_goToLogin(arguments: LoginArguments(LoginFormType.credentialForm));
|
||||
}
|
||||
} else if (failure is GetFCMSubscriptionLocalFailure){
|
||||
logoutAction();
|
||||
}
|
||||
},
|
||||
(success) {
|
||||
if (success is GetCredentialViewState) {
|
||||
@@ -201,4 +207,16 @@ abstract class ReloadableController extends BaseController {
|
||||
logError('ReloadableController::injectVacationBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getSubscriptionLocalAction() {
|
||||
try {
|
||||
_getSubscriptionLocalInteractor = Get.find<GetFCMSubscriptionLocalInteractor>();
|
||||
consumeState(_getSubscriptionLocalInteractor!.execute());
|
||||
} catch (e) {
|
||||
logError(
|
||||
'ReloadableController::getSubscriptionLocalAction(): exception: $e');
|
||||
logoutAction();
|
||||
}
|
||||
return Future.value();
|
||||
}
|
||||
}
|
||||
@@ -9,18 +9,17 @@ 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_fcm_subscription_local_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';
|
||||
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_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_subscription_interator.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_email_delivery_state_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_email_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_mailbox_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_subscription_interator.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource/thread_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/datasource_impl/thread_datasource_impl.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
@@ -65,7 +64,8 @@ class FcmInteractorBindings extends InteractorsBindings {
|
||||
Get.lazyPut(() => RegisterNewTokenInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => StoreMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => DestroySubscriptionInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => StoreSubscriptionInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetFCMSubscriptionLocalInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:tmail_ui_user/features/push_notification/domain/model/register_n
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_fcm_subscription_local.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_firebase_subscription_state.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/register_new_token_state.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_fcm_subscription_local_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/register_new_token_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/store_subscription_interator.dart';
|
||||
@@ -37,6 +38,7 @@ class FcmTokenHandler {
|
||||
StoreSubscriptionInteractor? _storeSubscriptionInteractor;
|
||||
GetFirebaseSubscriptionInteractor? _getFirebaseSubscriptionInteractor;
|
||||
RegisterNewTokenInteractor? _registerNewTokenInteractor;
|
||||
GetFCMSubscriptionLocalInteractor? _getFCMSubscriptionLocalInteractor;
|
||||
|
||||
FirebaseToken? _fcmToken;
|
||||
DeviceClientId? _deviceClientId;
|
||||
@@ -46,6 +48,7 @@ class FcmTokenHandler {
|
||||
_storeSubscriptionInteractor = getBinding<StoreSubscriptionInteractor>();
|
||||
_getFirebaseSubscriptionInteractor = getBinding<GetFirebaseSubscriptionInteractor>();
|
||||
_registerNewTokenInteractor = getBinding<RegisterNewTokenInteractor>();
|
||||
_getFCMSubscriptionLocalInteractor = getBinding<GetFCMSubscriptionLocalInteractor>();
|
||||
} catch (e) {
|
||||
logError('FcmTokenHandler::initialize(): ${e.toString()}');
|
||||
}
|
||||
@@ -60,6 +63,8 @@ class FcmTokenHandler {
|
||||
log('FcmTokenHandler::handle(): fcmToken: $_fcmToken');
|
||||
log('FcmTokenHandler::handle(): deviceId: $deviceId');
|
||||
_getFcmTokenFromBackend(deviceId);
|
||||
} else {
|
||||
_getFCMSubscriptionLocalAction();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,4 +183,10 @@ class FcmTokenHandler {
|
||||
_consumeState(_registerNewTokenInteractor!.execute(newTokenRequest));
|
||||
}
|
||||
}
|
||||
|
||||
void _getFCMSubscriptionLocalAction() {
|
||||
if (_getFCMSubscriptionLocalInteractor != null) {
|
||||
_consumeState(_getFCMSubscriptionLocalInteractor!.execute());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user