Use TupleKey(ObjectKey-AccountId-UserName) to store data to hive

(cherry picked from commit e0ace535d5f3af71eb13598d92524caf2c6d9bbf)
This commit is contained in:
dab246
2023-04-27 11:03:39 +07:00
committed by Dat Vu
parent 7d0a5729b2
commit 876cc368b0
107 changed files with 562 additions and 340 deletions
@@ -2,6 +2,7 @@ import 'package:fcm/model/firebase_subscription.dart';
import 'package:fcm/model/type_name.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
import 'package:jmap_dart_client/jmap/core/user_name.dart';
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_subscription.dart';
@@ -16,23 +17,23 @@ class CacheFCMDatasourceImpl extends FCMDatasource {
CacheFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower);
@override
Future<void> storeStateToRefresh(AccountId accountId, TypeName typeName, jmap.State newState) {
Future<void> storeStateToRefresh(AccountId accountId, UserName userName, TypeName typeName, jmap.State newState) {
return Future.sync(() async {
return await _firebaseCacheManager.storeStateToRefresh(accountId, typeName, newState);
return await _firebaseCacheManager.storeStateToRefresh(accountId, userName, typeName, newState);
}).catchError(_exceptionThrower.throwException);
}
@override
Future<jmap.State> getStateToRefresh(AccountId accountId, TypeName typeName) {
Future<jmap.State> getStateToRefresh(AccountId accountId,UserName userName, TypeName typeName) {
return Future.sync(() async {
return await _firebaseCacheManager.getStateToRefresh(accountId, typeName);
return await _firebaseCacheManager.getStateToRefresh(accountId, userName, typeName);
}).catchError(_exceptionThrower.throwException);
}
@override
Future<void> deleteStateToRefresh(AccountId accountId, TypeName typeName) {
Future<void> deleteStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) {
return Future.sync(() async {
return await _firebaseCacheManager.deleteStateToRefresh(accountId, typeName);
return await _firebaseCacheManager.deleteStateToRefresh(accountId, userName, typeName);
}).catchError(_exceptionThrower.throwException);
}
@@ -2,6 +2,7 @@ import 'package:fcm/model/firebase_subscription.dart';
import 'package:fcm/model/type_name.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
import 'package:jmap_dart_client/jmap/core/user_name.dart';
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_subscription.dart';
import 'package:tmail_ui_user/features/push_notification/data/network/fcm_api.dart';
@@ -24,17 +25,17 @@ class FcmDatasourceImpl extends FCMDatasource {
}
@override
Future<bool> deleteStateToRefresh(AccountId accountId, TypeName typeName) {
Future<bool> deleteStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) {
throw UnimplementedError();
}
@override
Future<jmap.State> getStateToRefresh(AccountId accountId, TypeName typeName) {
Future<jmap.State> getStateToRefresh(AccountId accountId, UserName userName, TypeName typeName) {
throw UnimplementedError();
}
@override
Future<bool> storeStateToRefresh(AccountId accountId, TypeName typeName, jmap.State newState) {
Future<bool> storeStateToRefresh(AccountId accountId, UserName userName, TypeName typeName, jmap.State newState) {
throw UnimplementedError();
}