From 44bb192a8f985609b2bfc031122e672f7819963a Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 25 Nov 2022 13:54:46 +0700 Subject: [PATCH] TF-438 Remove func not used --- .../presentation/config/fcm_configuration.dart | 1 - .../presentation/controller/fcm_controller.dart | 10 ++++++---- .../listener/email_change_listener.dart | 2 +- .../presentation/services/fcm_receiver.dart | 4 ---- .../presentation/services/fcm_service.dart | 13 ++----------- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/lib/features/push_notification/presentation/config/fcm_configuration.dart b/lib/features/push_notification/presentation/config/fcm_configuration.dart index 9d256e53b..33bf74f67 100644 --- a/lib/features/push_notification/presentation/config/fcm_configuration.dart +++ b/lib/features/push_notification/presentation/config/fcm_configuration.dart @@ -12,7 +12,6 @@ class FcmConfiguration { static void _initMessageListener() { FcmReceiver.instance.onForegroundMessage(); - FcmReceiver.instance.onMessageOpenedApp(); FcmReceiver.instance.onBackgroundMessage(); FcmReceiver.instance.getFcmToken(); } diff --git a/lib/features/push_notification/presentation/controller/fcm_controller.dart b/lib/features/push_notification/presentation/controller/fcm_controller.dart index 2fbe8baff..b41710fd3 100644 --- a/lib/features/push_notification/presentation/controller/fcm_controller.dart +++ b/lib/features/push_notification/presentation/controller/fcm_controller.dart @@ -142,10 +142,10 @@ class FcmController extends BaseController { FcmInteractorBindings().dependencies(); }); - _getInteractorBindings(); + return await _getInteractorBindings(); } - void _getInteractorBindings() { + Future _getInteractorBindings() { try { _getAuthenticatedAccountInteractor = Get.find(); _dynamicUrlInterceptors = Get.find(); @@ -154,9 +154,10 @@ class FcmController extends BaseController { } catch (e) { logError('FcmController::_getBindings(): ${e.toString()}'); } + return Future.value(null); } - void _getAuthenticatedAccount() async { + void _getAuthenticatedAccount() { if (_getAuthenticatedAccountInteractor != null) { consumeState(_getAuthenticatedAccountInteractor!.execute()); } else { @@ -171,6 +172,7 @@ class FcmController extends BaseController { } void _handleSuccessViewState(Success success) { + log('FcmController::_handleSuccessViewState(): $success'); if (success is GetStoredTokenOidcSuccess) { _getSessionWithTokenOidc(success); } else if (success is GetCredentialViewState) { @@ -198,7 +200,7 @@ class FcmController extends BaseController { _getSession(); } - void _getSession() async { + void _getSession() { if (_getSessionInteractor != null) { consumeState(_getSessionInteractor!.execute().asStream()); } else { diff --git a/lib/features/push_notification/presentation/listener/email_change_listener.dart b/lib/features/push_notification/presentation/listener/email_change_listener.dart index ac713041c..ca6a7c24a 100644 --- a/lib/features/push_notification/presentation/listener/email_change_listener.dart +++ b/lib/features/push_notification/presentation/listener/email_change_listener.dart @@ -123,7 +123,7 @@ class EmailChangeListener extends ChangeListener { ); } - void consumeState(Stream> newStateStream) async { + void consumeState(Stream> newStateStream) { newStateStream.listen( _handleStateStream, onError: (error, stackTrace) { diff --git a/lib/features/push_notification/presentation/services/fcm_receiver.dart b/lib/features/push_notification/presentation/services/fcm_receiver.dart index 71a4d9fb5..6d2881805 100644 --- a/lib/features/push_notification/presentation/services/fcm_receiver.dart +++ b/lib/features/push_notification/presentation/services/fcm_receiver.dart @@ -21,10 +21,6 @@ class FcmReceiver { FirebaseMessaging.onMessage.listen(FcmService.instance.handleFirebaseForegroundMessage); } - void onMessageOpenedApp() { - FirebaseMessaging.onMessageOpenedApp.listen(FcmService.instance.handleFirebaseMessageOpenedApp); - } - void onBackgroundMessage() { FirebaseMessaging.onBackgroundMessage(handleFirebaseBackgroundMessage); } diff --git a/lib/features/push_notification/presentation/services/fcm_service.dart b/lib/features/push_notification/presentation/services/fcm_service.dart index db78a56b0..62e1326b1 100644 --- a/lib/features/push_notification/presentation/services/fcm_service.dart +++ b/lib/features/push_notification/presentation/services/fcm_service.dart @@ -17,7 +17,6 @@ class FcmService { Stream get backgroundMessageStream => backgroundMessageStreamController.stream; FirebaseToken? currentToken; - int semaphore = 0; FcmService._internal(); @@ -26,12 +25,8 @@ class FcmService { static FcmService get instance => _instance; void handleFirebaseForegroundMessage(RemoteMessage newRemoteMessage) { - if (semaphore != 0) { - return; - } - semaphore = 1; - Future.delayed(const Duration(milliseconds: durationMessageComing)).then((_) => semaphore = 0); - + log('FcmService::handleFirebaseForegroundMessage():messageId: ${newRemoteMessage.messageId}'); + log('FcmService::handleFirebaseForegroundMessage():message: ${newRemoteMessage.data}'); foregroundMessageStreamController.add(newRemoteMessage); } @@ -40,10 +35,6 @@ class FcmService { backgroundMessageStreamController.add(newRemoteMessage); } - void handleFirebaseMessageOpenedApp(RemoteMessage newRemoteMessage) { - log('FcmService::handleFirebaseMessageOpenedApp():newRemoteMessage: ${newRemoteMessage.data}'); - } - void _closeStream() { foregroundMessageStreamController.close(); backgroundMessageStreamController.close();