TF-1289: [Presentation] Refactor name function
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/caching/mailbox_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/mailbox/data/model/state_type.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
|
||||
|
||||
@@ -16,6 +17,7 @@ class CachingManager {
|
||||
final RecentSearchCacheClient _recentSearchCacheClient;
|
||||
final AccountCacheClient _accountCacheClient;
|
||||
final FCMCacheManager _fcmCacheManager;
|
||||
final FCMSubscriptionCacheClient _fcmSubscriptionCacheClient;
|
||||
|
||||
CachingManager(
|
||||
this._mailboxCacheClient,
|
||||
@@ -24,6 +26,7 @@ class CachingManager {
|
||||
this._recentSearchCacheClient,
|
||||
this._accountCacheClient,
|
||||
this._fcmCacheManager,
|
||||
this._fcmSubscriptionCacheClient,
|
||||
);
|
||||
|
||||
Future<void> clearAll() async {
|
||||
@@ -33,6 +36,7 @@ class CachingManager {
|
||||
_emailCacheClient.clearAllData(),
|
||||
_recentSearchCacheClient.clearAllData(),
|
||||
_accountCacheClient.clearAllData(),
|
||||
_fcmSubscriptionCacheClient.clearAllData(),
|
||||
_fcmCacheManager.clearAllStateToRefresh()
|
||||
]);
|
||||
}
|
||||
|
||||
+1
-7
@@ -1400,13 +1400,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
void popAllRouteIfHave() {
|
||||
Get.until((route) => Get.currentRoute == AppRoutes.dashboard);
|
||||
}
|
||||
|
||||
@override
|
||||
void logoutAction() {
|
||||
popBack();
|
||||
super.logoutAction();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_emailReceiveManager.closeEmailReceiveManagerStream();
|
||||
|
||||
@@ -319,7 +319,8 @@ class MailboxDashBoardView extends BaseMailboxDashBoardView {
|
||||
controller.openPopupMenuAction(context, position, popupMenuUserSettingActionTile(context,
|
||||
controller.userProfile.value,
|
||||
onLogoutAction: () {
|
||||
controller.logout(controller.sessionCurrent, controller.accountId.value);
|
||||
popBack();
|
||||
controller.logout(controller.sessionCurrent, controller.accountId.value);
|
||||
},
|
||||
onSettingAction: () {
|
||||
popBack();
|
||||
|
||||
@@ -299,10 +299,4 @@ class ManageAccountDashBoardController extends ReloadableController {
|
||||
dashboardSettingAction.value = newAction;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void logoutAction() {
|
||||
popBack();
|
||||
super.logoutAction();
|
||||
}
|
||||
}
|
||||
@@ -142,7 +142,8 @@ class ManageAccountDashBoardView extends GetWidget<ManageAccountDashBoardControl
|
||||
controller.openPopupMenuAction(context, position, popupMenuUserSettingActionTile(context,
|
||||
controller.userProfile.value,
|
||||
onLogoutAction: () {
|
||||
controller.logout(controller.sessionCurrent.value, controller.accountId.value);
|
||||
popBack();
|
||||
controller.logout(controller.sessionCurrent.value, controller.accountId.value);
|
||||
},
|
||||
onSettingAction: () {
|
||||
popBack();
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/manage_account_dashboard_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/menu/manage_account_menu_controller.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/settings_page_level.dart';
|
||||
|
||||
class SettingsController extends GetxController {
|
||||
final manageAccountDashboardController = Get.find<ManageAccountDashBoardController>();
|
||||
final manageAccountMenuController = Get.find<ManageAccountMenuController>();
|
||||
|
||||
|
||||
void selectSettings(AccountMenuItem accountMenuItem) {
|
||||
log('SettingsController::selectSettings(): $accountMenuItem');
|
||||
|
||||
+3
-1
@@ -119,7 +119,9 @@ class SettingsFirstLevelView extends GetWidget<SettingsController> {
|
||||
SettingFirstLevelTileBuilder(
|
||||
AppLocalizations.of(context).sign_out,
|
||||
_imagePaths.icSignOut,
|
||||
controller.manageAccountMenuController.logout,
|
||||
() => controller.manageAccountDashboardController.logout(
|
||||
controller.manageAccountDashboardController.sessionCurrent.value,
|
||||
controller.manageAccountDashboardController.accountId.value)
|
||||
),
|
||||
]),
|
||||
);
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
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: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';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class CacheFCMDatasourceImpl extends FCMDatasource {
|
||||
|
||||
final FCMCacheManager _firebaseCacheManager;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
CacheFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<bool> storeStateToRefresh(TypeName typeName, jmap.State newState) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.storeStateToRefresh(typeName, newState);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<jmap.State> getStateToRefresh(TypeName typeName) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.getStateToRefresh(typeName);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> deleteStateToRefresh(TypeName typeName) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.deleteStateToRefresh(typeName);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FirebaseSubscription> getFirebaseSubscriptionByDeviceId(String deviceId) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest newTokenRequest) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> storeSubscription(FCMSubscriptionCache fcmSubscriptionCache) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.storeSubscription(fcmSubscriptionCache);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
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: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';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class HiveFCMDatasourceImpl extends FCMDatasource {
|
||||
|
||||
final FCMCacheManager _firebaseCacheManager;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
HiveFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<bool> storeStateToRefresh(TypeName typeName, jmap.State newState) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.storeStateToRefresh(typeName, newState);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<jmap.State> getStateToRefresh(TypeName typeName) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.getStateToRefresh(typeName);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> deleteStateToRefresh(TypeName typeName) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.deleteStateToRefresh(typeName);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> storeDeviceId(String deviceId) {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.storeDeviceId(deviceId);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FirebaseSubscription> getFirebaseSubscriptionByDeviceId(String deviceId) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest newTokenRequest) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> getDeviceId() {
|
||||
return Future.sync(() async {
|
||||
return await _firebaseCacheManager.getDeviceId();
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class FCMCacheManager {
|
||||
return await Future.wait([
|
||||
_sharedPreferences.remove(TypeName.emailType.value),
|
||||
_sharedPreferences.remove(TypeName.mailboxType.value),
|
||||
_sharedPreferences.remove(TypeName.emailDelivery.value)
|
||||
_sharedPreferences.remove(TypeName.emailDelivery.value),
|
||||
]).then((listResult) => listResult.every((result) => result));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ class FcmApi {
|
||||
final processingInvocation = ProcessingInvocation();
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, processingInvocation);
|
||||
|
||||
final firebaseSubscriptionSetMethod = FirebaseSubscriptionSetMethod();
|
||||
final firebaseSubscriptionSetMethod = FirebaseSubscriptionSetMethod()..addDestroy({Id(subscriptionId)});
|
||||
final firebaseSubscriptionSetInvocation = requestBuilder.invocation(firebaseSubscriptionSetMethod);
|
||||
final response = await (requestBuilder
|
||||
..usings({
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class GetDeviceIdLoading extends UIState {}
|
||||
|
||||
class GetDeviceIdSuccess extends UIState {
|
||||
|
||||
final String deviceId;
|
||||
|
||||
GetDeviceIdSuccess(this.deviceId);
|
||||
|
||||
@override
|
||||
List<Object> get props => [deviceId];
|
||||
}
|
||||
|
||||
class GetDeviceIdFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
GetDeviceIdFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
|
||||
class StoreDeviceIdLoading extends UIState {}
|
||||
|
||||
class StoreDeviceIdSuccess extends UIState {
|
||||
|
||||
StoreDeviceIdSuccess();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class StoreDeviceIdFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
StoreDeviceIdFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_device_id_state.dart';
|
||||
|
||||
class GetDeviceIdInteractor {
|
||||
final FCMRepository _fcmRepository;
|
||||
|
||||
GetDeviceIdInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(GetDeviceIdLoading());
|
||||
final deviceId = await _fcmRepository.getDeviceId();
|
||||
yield Right<Failure, Success>(GetDeviceIdSuccess(deviceId));
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(GetDeviceIdFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/state/store_device_id_state.dart';
|
||||
|
||||
class StoreDeviceIdInteractor {
|
||||
final FCMRepository _fcmRepository;
|
||||
|
||||
StoreDeviceIdInteractor(this._fcmRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(String deviceId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(StoreDeviceIdLoading());
|
||||
await _fcmRepository.storeDeviceId(deviceId);
|
||||
yield Right<Failure, Success>(StoreDeviceIdSuccess());
|
||||
} catch (e) {
|
||||
yield Left<Failure, Success>(StoreDeviceIdFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import 'package:tmail_ui_user/features/push_notification/data/network/fcm_api.da
|
||||
import 'package:tmail_ui_user/features/push_notification/data/repository/fcm_repository_impl.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_email_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/destroy_subscription_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_changes_to_push_notification_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_email_state_to_refresh_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_fcm_subscription_local_interactor.dart';
|
||||
@@ -66,6 +67,7 @@ class FcmInteractorBindings extends InteractorsBindings {
|
||||
Get.lazyPut(() => GetMailboxStateToRefreshInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => StoreSubscriptionInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => GetFCMSubscriptionLocalInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
Get.lazyPut(() => DestroySubscriptionInteractor(Get.find<FCMRepositoryImpl>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -65,7 +65,8 @@ class LocalBindings extends Bindings {
|
||||
Get.find<EmailCacheClient>(),
|
||||
Get.find<RecentSearchCacheClient>(),
|
||||
Get.find<AccountCacheClient>(),
|
||||
Get.find<FCMCacheManager>()
|
||||
Get.find<FCMCacheManager>(),
|
||||
Get.find<FCMSubscriptionCacheClient>(),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user