TF-1289: [Data] Implement DestroySubscription in fcm datasource

This commit is contained in:
HuyNguyen
2022-12-29 18:01:57 +07:00
committed by Dat Vu
parent 37e7013dd5
commit 5219cd4b69
4 changed files with 19 additions and 1 deletions
@@ -19,4 +19,6 @@ abstract class FCMDatasource {
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest newTokenRequest);
Future<FCMSubscriptionCache> geSubscription();
Future<bool> destroySubscription(String subscriptionId);
}
@@ -68,4 +68,9 @@ class CacheFCMDatasourceImpl extends FCMDatasource {
_exceptionThrower.throwException(error);
});
}
@override
Future<bool> destroySubscription(String subscriptionId) {
throw UnimplementedError();
}
}
@@ -58,4 +58,13 @@ class FcmDatasourceImpl extends FCMDatasource {
Future<FCMSubscriptionCache> geSubscription() {
throw UnimplementedError();
}
@override
Future<bool> destroySubscription(String subscriptionId) {
return Future.sync(() async {
return await _fcmApi.destroySubscription(subscriptionId);
}).catchError((error) {
_exceptionThrower.throwException(error);
});
}
}
+3 -1
View File
@@ -11,6 +11,7 @@ import 'package:tmail_ui_user/features/caching/recent_login_url_cache_client.dar
import 'package:tmail_ui_user/features/caching/recent_login_username_cache_client.dart';
import 'package:tmail_ui_user/features/caching/recent_search_cache_client.dart';
import 'package:tmail_ui_user/features/caching/state_cache_client.dart';
import 'package:tmail_ui_user/features/caching/subscription_cache_client.dart';
import 'package:tmail_ui_user/features/caching/token_oidc_cache_client.dart';
import 'package:tmail_ui_user/features/cleanup/data/local/recent_login_url_cache_manager.dart';
import 'package:tmail_ui_user/features/cleanup/data/local/recent_login_username_cache_manager.dart';
@@ -56,7 +57,8 @@ class LocalBindings extends Bindings {
Get.put(RecentLoginUrlCacheManager((Get.find<RecentLoginUrlCacheClient>())));
Get.put(RecentLoginUsernameCacheClient());
Get.put(RecentLoginUsernameCacheManager(Get.find<RecentLoginUsernameCacheClient>()));
Get.put(FCMCacheManager(Get.find<SharedPreferences>()));
Get.put(FCMSubscriptionCacheClient());
Get.put(FCMCacheManager(Get.find<SharedPreferences>(),Get.find<FCMSubscriptionCacheClient>()));
Get.put(CachingManager(
Get.find<MailboxCacheClient>(),
Get.find<StateCacheClient>(),