TF-2464 Fix can not auto refresh list email when switch background mode to foreground mode

(cherry picked from commit 34b09c0aeacb8bc42cf7196adca2c65aa7eb47e9)
This commit is contained in:
dab246
2024-01-18 13:57:19 +07:00
committed by Dat PHAM HOANG
parent 274e01d113
commit 1835e9fad7
3 changed files with 3 additions and 23 deletions
@@ -28,7 +28,7 @@ class CacheFCMDatasourceImpl extends FCMDatasource {
}
@override
Future<jmap.State> getStateToRefresh(AccountId accountId,UserName userName, TypeName typeName) {
Future<jmap.State> getStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) {
return Future.sync(() async {
return await _firebaseCacheManager.getStateToRefresh(accountId, userName, typeName);
}).catchError(_exceptionThrower.throwException);
@@ -22,7 +22,7 @@ class FCMCacheManager {
Future<jmap.State> getStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) async {
final stateKeyCache = TupleKey(typeName.value, accountId.asString, userName.value).encodeKey;
final stateValue = await _fcmCacheClient.getItem(stateKeyCache);
final stateValue = await _fcmCacheClient.getItem(stateKeyCache, needToReopen: true);
if (stateValue != null) {
return jmap.State(stateValue);
} else {
@@ -51,7 +51,7 @@ class FCMCacheManager {
}
Future<FirebaseRegistrationCache> getStoredFirebaseRegistration() async {
final firebaseRegistration = await _firebaseRegistrationCacheClient.getItem(FirebaseRegistrationCache.keyCacheValue);
final firebaseRegistration = await _firebaseRegistrationCacheClient.getItem(FirebaseRegistrationCache.keyCacheValue, needToReopen: true);
if (firebaseRegistration == null) {
throw NotFoundFirebaseRegistrationCacheException();
} else {
@@ -62,11 +62,4 @@ class FCMCacheManager {
Future<void> deleteFirebaseRegistration() async {
await _firebaseRegistrationCacheClient.deleteItem(FirebaseRegistrationCache.keyCacheValue);
}
Future<void> closeCacheBox() async {
await Future.wait([
_fcmCacheClient.closeBox(),
_firebaseRegistrationCacheClient.closeBox(),
]);
}
}