Fix: Update EmailDeliveryState to Keychain
Signed-off-by: dab246 <tdvu@linagora.com> (cherry picked from commit ac72825c7bb5840a8d779d0d1a0a336c75ade232)
This commit is contained in:
@@ -59,6 +59,7 @@ import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_isolate_worker.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
import 'package:tmail_ui_user/main/utils/ios_sharing_manager.dart';
|
||||
|
||||
class FcmInteractorBindings extends InteractorsBindings {
|
||||
|
||||
@@ -102,6 +103,7 @@ class FcmInteractorBindings extends InteractorsBindings {
|
||||
Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(
|
||||
Get.find<StateCacheManager>(),
|
||||
Get.find<IOSSharingManager>(),
|
||||
Get.find<CacheExceptionThrower>()
|
||||
));
|
||||
Get.lazyPut(() => EmailHiveCacheDataSourceImpl(
|
||||
|
||||
@@ -47,6 +47,7 @@ import 'package:tmail_ui_user/features/push_notification/presentation/listener/c
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_manager.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/constants/thread_constants.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
import 'package:tmail_ui_user/main/utils/ios_sharing_manager.dart';
|
||||
|
||||
class EmailChangeListener extends ChangeListener {
|
||||
|
||||
@@ -62,6 +63,7 @@ class EmailChangeListener extends ChangeListener {
|
||||
GetListDetailedEmailByIdInteractor? _getListDetailedEmailByIdInteractor;
|
||||
DynamicUrlInterceptors? _dynamicUrlInterceptors;
|
||||
StoreListNewEmailInteractor? _storeListNewEmailInteractor;
|
||||
IOSSharingManager? _iosSharingManager;
|
||||
|
||||
jmap.State? _newStateEmailDelivery;
|
||||
AccountId? _accountId;
|
||||
@@ -83,6 +85,7 @@ class EmailChangeListener extends ChangeListener {
|
||||
_getListDetailedEmailByIdInteractor = getBinding<GetListDetailedEmailByIdInteractor>();
|
||||
_dynamicUrlInterceptors = getBinding<DynamicUrlInterceptors>();
|
||||
_storeListNewEmailInteractor = getBinding<StoreListNewEmailInteractor>();
|
||||
_iosSharingManager = getBinding<IOSSharingManager>();
|
||||
} catch (e) {
|
||||
logError('EmailChangeListener::_internal(): IS NOT REGISTERED: ${e.toString()}');
|
||||
}
|
||||
@@ -133,8 +136,11 @@ class EmailChangeListener extends ChangeListener {
|
||||
_userName = userName;
|
||||
log('EmailChangeListener::_pushNotificationAction():newState: $newState');
|
||||
|
||||
if (PlatformInfo.isWeb || PlatformInfo.isIOS) {
|
||||
if (PlatformInfo.isWeb) {
|
||||
_storeEmailDeliveryStateAction(accountId, userName, _newStateEmailDelivery!);
|
||||
} else if (PlatformInfo.isIOS) {
|
||||
_storeEmailDeliveryStateAction(accountId, userName, _newStateEmailDelivery!);
|
||||
_updateKeychainSharingSession(accountId, _newStateEmailDelivery!.value);
|
||||
} else if (PlatformInfo.isAndroid) {
|
||||
_getStoredEmailDeliveryState(accountId, userName);
|
||||
}
|
||||
@@ -322,4 +328,15 @@ class EmailChangeListener extends ChangeListener {
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void _updateKeychainSharingSession(AccountId accountId, String emailDeliveryState) async {
|
||||
if (_iosSharingManager == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final emailDeliveryStateKeychain = await _iosSharingManager!.getEmailDeliveryStateFromKeychain(accountId);
|
||||
if (emailDeliveryStateKeychain == null || emailDeliveryStateKeychain.isEmpty) {
|
||||
await _iosSharingManager!.updateEmailDeliveryStateInKeyChain(accountId, emailDeliveryState);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user