Store and get fcm cache by AccountId

(cherry picked from commit e327dff45a4fc67d0c5a2d2afe64fc4673e2eac1)
This commit is contained in:
dab246
2023-04-25 18:15:02 +07:00
committed by Dat Vu
parent eb27022a08
commit 550752a2a4
23 changed files with 130 additions and 107 deletions
@@ -90,7 +90,7 @@ class EmailChangeListener extends ChangeListener {
if (FcmUtils.instance.isMobileAndroid) {
_handleRemoveNotificationWhenEmailMarkAsRead(action.newState, action.accountId, action.session);
}
_handleStoreEmailStateToRefreshAction(action.newState);
_handleStoreEmailStateToRefreshAction(action.accountId, action.newState);
}
}
}
@@ -109,22 +109,22 @@ class EmailChangeListener extends ChangeListener {
log('EmailChangeListener::_pushNotificationAction():newState: $newState');
if (BuildUtils.isWeb) {
_storeEmailDeliveryStateAction(_newStateEmailDelivery!);
_storeEmailDeliveryStateAction(accountId, _newStateEmailDelivery!);
} else {
if (Platform.isAndroid) {
_getStoredEmailDeliveryState();
_getStoredEmailDeliveryState(accountId);
} else if (Platform.isIOS) {
_storeEmailDeliveryStateAction(_newStateEmailDelivery!);
_showLocalNotificationForIOS(_newStateEmailDelivery!, _accountId!);
_storeEmailDeliveryStateAction(accountId, _newStateEmailDelivery!);
_showLocalNotificationForIOS(_newStateEmailDelivery!, accountId);
} else {
logError('EmailChangeListener::_pushNotificationAction(): NOT SUPPORTED PLATFORM');
}
}
}
void _getStoredEmailDeliveryState() {
void _getStoredEmailDeliveryState(AccountId accountId) {
if (_getStoredEmailDeliveryStateInteractor != null) {
consumeState(_getStoredEmailDeliveryStateInteractor!.execute());
consumeState(_getStoredEmailDeliveryStateInteractor!.execute(accountId));
}
}
@@ -148,9 +148,9 @@ class EmailChangeListener extends ChangeListener {
}
}
void _storeEmailDeliveryStateAction(jmap.State state) {
void _storeEmailDeliveryStateAction(AccountId accountId, jmap.State state) {
if (_storeEmailDeliveryStateInteractor != null) {
consumeState(_storeEmailDeliveryStateInteractor!.execute(state));
consumeState(_storeEmailDeliveryStateInteractor!.execute(accountId, state));
}
}
@@ -204,7 +204,7 @@ class EmailChangeListener extends ChangeListener {
_getEmailChangesAction(success.state);
} else if (success is GetEmailChangesToPushNotificationSuccess) {
if (_newStateEmailDelivery != null) {
_storeEmailDeliveryStateAction(_newStateEmailDelivery!);
_storeEmailDeliveryStateAction(success.accountId, _newStateEmailDelivery!);
if (FcmUtils.instance.isMobileAndroid) {
_handleListEmailToPushNotification(success.emailList);
@@ -244,10 +244,10 @@ class EmailChangeListener extends ChangeListener {
_emailsAvailablePushNotification.clear();
}
void _handleStoreEmailStateToRefreshAction(jmap.State newState) {
void _handleStoreEmailStateToRefreshAction(AccountId accountId, jmap.State newState) {
log('EmailChangeListener::_handleStoreEmailStateToRefreshAction():newState: $newState');
if (_storeEmailStateToRefreshInteractor != null) {
consumeState(_storeEmailStateToRefreshInteractor!.execute(newState));
consumeState(_storeEmailStateToRefreshInteractor!.execute(accountId, newState));
} else {
logError('EmailChangeListener::_handleStoreEmailStateToRefreshAction():_storeEmailStateToRefreshInteractor is null');
}
@@ -2,6 +2,7 @@
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:core/utils/app_logger.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
import 'package:tmail_ui_user/features/base/action/ui_action.dart';
import 'package:tmail_ui_user/features/mailbox/presentation/action/mailbox_ui_action.dart';
@@ -36,7 +37,7 @@ class MailboxChangeListener extends ChangeListener {
if (action is SynchronizeMailboxOnForegroundAction) {
_synchronizeMailboxOnForegroundAction(action.newState);
} else if (action is StoreMailboxStateToRefreshAction) {
_handleStoreMailboxStateToRefreshAction(action.newState);
_handleStoreMailboxStateToRefreshAction(action.accountId, action.newState);
}
}
}
@@ -58,10 +59,10 @@ class MailboxChangeListener extends ChangeListener {
}
}
void _handleStoreMailboxStateToRefreshAction(jmap.State newState) {
void _handleStoreMailboxStateToRefreshAction(AccountId accountId, jmap.State newState) {
log('MailboxChangeListener::_handleStoreMailboxStateToRefreshAction():newState: $newState');
if (_storeMailboxStateToRefreshInteractor != null) {
consumeState(_storeMailboxStateToRefreshInteractor!.execute(newState));
consumeState(_storeMailboxStateToRefreshInteractor!.execute(accountId, newState));
}
}
}