TF-439 Delete all class not used
This commit is contained in:
@@ -1,17 +1,10 @@
|
||||
|
||||
import 'package:fcm/model/firebase_subscription.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
|
||||
|
||||
abstract class FCMDatasource {
|
||||
Future<FCMTokenDto> getFCMToken(String accountId);
|
||||
|
||||
Future<void> setFCMToken(FCMTokenDto fcmToken);
|
||||
|
||||
Future<void> deleteFCMToken(String accountId);
|
||||
|
||||
Future<bool> storeStateToRefresh(TypeName typeName, jmap.State newState);
|
||||
|
||||
Future<jmap.State> getStateToRefresh(TypeName typeName);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fcm/model/firebase_subscription.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/network/fcm_api.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
|
||||
@@ -23,31 +22,16 @@ class FcmDatasourceImpl extends FCMDatasource {
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteFCMToken(String accountId) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> deleteStateToRefresh(TypeName typeName) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FCMTokenDto> getFCMToken(String accountId) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<jmap.State> getStateToRefresh(TypeName typeName) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setFCMToken(FCMTokenDto fcmToken) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> storeDeviceId(String deviceId) {
|
||||
throw UnimplementedError();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fcm/model/firebase_subscription.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
import 'package:model/fcm/fcm_token_dto.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/domain/model/register_new_token_request.dart';
|
||||
@@ -14,33 +13,6 @@ class HiveFCMDatasourceImpl extends FCMDatasource {
|
||||
|
||||
HiveFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<FCMTokenDto> getFCMToken(String accountId) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.getFCMToken(accountId);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setFCMToken(FCMTokenDto fcmToken) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.setFCMToken(fcmToken);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteFCMToken(String accountId) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.deleteFCMToken(accountId);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> storeStateToRefresh(TypeName typeName, jmap.State newState) {
|
||||
return Future.sync(() async {
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_token_cache.dart';
|
||||
|
||||
extension FCMCacheExtension on FCMTokenCache {
|
||||
FCMTokenDto toFCMDto() {
|
||||
return FCMTokenDto(
|
||||
token,
|
||||
accountId,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_token_cache.dart';
|
||||
|
||||
extension FCMExtensions on FCMTokenDto {
|
||||
FCMTokenCache toCache() {
|
||||
return FCMTokenCache(
|
||||
token,
|
||||
accountId,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +1,15 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:fcm/model/type_name.dart';
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tmail_ui_user/features/caching/fcm_token_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/fcm_cache_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/fcm_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/fcm_exception.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
|
||||
|
||||
class FCMCacheManager {
|
||||
final FcmTokenCacheClient _fcmTokenCacheClient;
|
||||
final SharedPreferences _sharedPreferences;
|
||||
|
||||
static const String fcmDeviceIdKey = 'FCM_DEVICE_ID';
|
||||
|
||||
FCMCacheManager(this._fcmTokenCacheClient, this._sharedPreferences);
|
||||
|
||||
Future<FCMTokenDto> getFCMToken(String accountId) async {
|
||||
try {
|
||||
final firebase = await _fcmTokenCacheClient.getItem(accountId);
|
||||
if(firebase != null ) {
|
||||
return firebase.toFCMDto();
|
||||
} else {
|
||||
throw NotFoundStoredFCMException();
|
||||
}
|
||||
} catch (e) {
|
||||
logError('FCMCacheManager::getFCM(): $e');
|
||||
throw NotFoundStoredFCMException();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setFCMToken(FCMTokenDto firebaseDto) {
|
||||
log('FCMCacheManager::setFCM(): $_fcmTokenCacheClient');
|
||||
return _fcmTokenCacheClient.insertItem(firebaseDto.accountId, firebaseDto.toCache());
|
||||
}
|
||||
|
||||
Future<void> deleteFCMToken(String accountId) {
|
||||
log('FCMCacheManager::deleteSelectedFCM(): $accountId');
|
||||
return _fcmTokenCacheClient.deleteItem(accountId);
|
||||
}
|
||||
FCMCacheManager(this._sharedPreferences);
|
||||
|
||||
Future<bool> storeStateToRefresh(TypeName typeName, jmap.State newState) {
|
||||
return _sharedPreferences.setString(typeName.value, newState.value);
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart';
|
||||
|
||||
part 'fcm_token_cache.g.dart';
|
||||
|
||||
@HiveType(typeId: CachingConstants.FCM_TOKEN_CACHE_IDENTITY)
|
||||
class FCMTokenCache extends HiveObject with EquatableMixin {
|
||||
@HiveField(0)
|
||||
final String token;
|
||||
|
||||
@HiveField(1)
|
||||
final String accountId;
|
||||
|
||||
FCMTokenCache(
|
||||
this.token,
|
||||
this.accountId,
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [token, accountId];
|
||||
}
|
||||
@@ -3,7 +3,6 @@ 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/properties/properties.dart';
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
@@ -22,21 +21,6 @@ class FCMRepositoryImpl extends FCMRepository {
|
||||
this._threadDataSource
|
||||
);
|
||||
|
||||
@override
|
||||
Future<FCMTokenDto> getFCMToken(String accountId) {
|
||||
return _fcmDatasource[DataSourceType.local]!.getFCMToken(accountId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> setFCMToken(FCMTokenDto fcmTokenDto) {
|
||||
return _fcmDatasource[DataSourceType.local]!.setFCMToken(fcmTokenDto);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> deleteFCMToken(String accountId) {
|
||||
return _fcmDatasource[DataSourceType.local]!.deleteFCMToken(accountId);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<EmailsResponse> getEmailChangesToPushNotification(
|
||||
AccountId accountId,
|
||||
|
||||
Reference in New Issue
Block a user