TF-4193 Fix all Nitpick comments from coderabbit

This commit is contained in:
dab246
2025-12-10 12:10:17 +07:00
committed by Dat H. Pham
parent ef2ab39a3a
commit 6b1c7e23dc
33 changed files with 20 additions and 91 deletions
@@ -40,10 +40,7 @@ class DownloadDatasourceImpl extends DownloadDatasource {
onReceiveController: onReceiveController, onReceiveController: onReceiveController,
cancelToken: cancelToken, cancelToken: cancelToken,
); );
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
@override @override
@@ -67,9 +64,6 @@ class DownloadDatasourceImpl extends DownloadDatasource {
onReceiveController: onReceiveController, onReceiveController: onReceiveController,
cancelToken: cancelToken, cancelToken: cancelToken,
); );
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
} }
@@ -14,19 +14,13 @@ class LabelDatasourceImpl extends LabelDatasource {
Future<List<Label>> getAllLabels(AccountId accountId) { Future<List<Label>> getAllLabels(AccountId accountId) {
return Future.sync(() async { return Future.sync(() async {
return await _labelApi.getAllLabels(accountId); return await _labelApi.getAllLabels(accountId);
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
@override @override
Future<Label> createNewLabel(AccountId accountId, Label labelData) { Future<Label> createNewLabel(AccountId accountId, Label labelData) {
return Future.sync(() async { return Future.sync(() async {
return await _labelApi.createNewLabel(accountId, labelData); return await _labelApi.createNewLabel(accountId, labelData);
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
} }
@@ -180,9 +180,6 @@ class AuthenticationOIDCDataSourceImpl extends AuthenticationOIDCDataSource {
Future<OidcUserInfo> fetchUserInfo(String userInfoEndpoint) { Future<OidcUserInfo> fetchUserInfo(String userInfoEndpoint) {
return Future.sync(() async { return Future.sync(() async {
return await _oidcHttpClient.fetchUserInfo(userInfoEndpoint); return await _oidcHttpClient.fetchUserInfo(userInfoEndpoint);
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
} }
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart'; import 'package:tmail_ui_user/features/login/domain/repository/credential_repository.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -187,9 +187,6 @@ class MailboxDataSourceImpl extends MailboxDataSource {
onProgressController: onProgressController, onProgressController: onProgressController,
); );
} }
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
} }
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:core/utils/app_logger.dart'; import 'package:core/utils/app_logger.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -82,22 +82,16 @@ class ManageAccountDataSourceImpl extends ManageAccountDataSource {
@override @override
Future<bool> getLabelVisibility() { Future<bool> getLabelVisibility() {
return Future.sync(() async { return Future.sync(() {
return await _settingCacheManager.getLabelVisibility(); return _settingCacheManager.getLabelVisibility();
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
@override @override
Future<void> saveLabelVisibility(bool visible) { Future<void> saveLabelVisibility(bool visible) {
return Future.sync(() async { return Future.sync(() async {
return await _settingCacheManager.saveLabelVisibility(visible); return await _settingCacheManager.saveLabelVisibility(visible);
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
@override @override
@@ -105,9 +99,6 @@ class ManageAccountDataSourceImpl extends ManageAccountDataSource {
return Future.sync(() async { return Future.sync(() async {
final labelConfig = await _preferencesSettingManager.getLabelConfig(); final labelConfig = await _preferencesSettingManager.getLabelConfig();
return labelConfig.isEnabled; return labelConfig.isEnabled;
}).catchError((error, stackTrace) async { }).catchError(_exceptionThrower.throwException);
await _exceptionThrower.throwException(error, stackTrace);
throw error;
});
} }
} }
@@ -7,8 +7,7 @@ class SettingCacheManager {
final SharedPreferences _sharedPreferences; final SharedPreferences _sharedPreferences;
Future<bool> getLabelVisibility() async { bool getLabelVisibility() {
await _sharedPreferences.reload();
return _sharedPreferences.getBool(_labelVisibilitySettingKey) ?? false; return _sharedPreferences.getBool(_labelVisibilitySettingKey) ?? false;
} }
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/core.dart'; import 'package:core/core.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/account_id.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -13,8 +13,8 @@ class GetLabelSettingStateInteractor {
Stream<Either<Failure, Success>> execute(AccountId accountId) async* { Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
try { try {
yield Right(GettingLabelSettingState()); yield Right(GettingLabelSettingState());
final isEnable = await _manageAccountRepository.getLabelSettingState(); final isEnabled = await _manageAccountRepository.getLabelSettingState();
yield Right(GetLabelSettingStateSuccess(isEnable, accountId)); yield Right(GetLabelSettingStateSuccess(isEnabled, accountId));
} catch (e) { } catch (e) {
yield Left(GetLabelSettingStateFailure(e)); yield Left(GetLabelSettingStateFailure(e));
} }
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -1,4 +1,3 @@
import 'dart:core';
import 'dart:ui'; import 'dart:ui';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:core/utils/app_logger.dart'; import 'package:core/utils/app_logger.dart';
@@ -1,5 +1,3 @@
import 'dart:core';
import 'package:core/presentation/state/failure.dart'; import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart'; import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
@@ -18,7 +18,7 @@ extension HandleSetupLabelVisibilityInSettingExtension
} }
void enableLabelVisibility() { void enableLabelVisibility() {
isLabelVisibility.value = true; isLabelVisibilityEnabled.value = true;
saveLabelVisibilityInteractor = getBinding<SaveLabelVisibilityInteractor>(); saveLabelVisibilityInteractor = getBinding<SaveLabelVisibilityInteractor>();
if (saveLabelVisibilityInteractor != null) { if (saveLabelVisibilityInteractor != null) {
@@ -41,6 +41,6 @@ extension HandleSetupLabelVisibilityInSettingExtension
} }
void handleGetLabelVisibilitySuccess(bool visible) { void handleGetLabelVisibilitySuccess(bool visible) {
isLabelVisibility.value = visible; isLabelVisibilityEnabled.value = visible;
} }
} }
@@ -77,7 +77,7 @@ class ManageAccountDashBoardController extends ReloadableController
final vacationResponse = Rxn<VacationResponse>(); final vacationResponse = Rxn<VacationResponse>();
final dashboardSettingAction = Rxn<UIAction>(); final dashboardSettingAction = Rxn<UIAction>();
final octetsQuota = Rxn<Quota>(); final octetsQuota = Rxn<Quota>();
final isLabelVisibility = RxBool(false); final isLabelVisibilityEnabled = RxBool(false);
Uri? previousUri; Uri? previousUri;
AccountMenuItem? selectedMenu; AccountMenuItem? selectedMenu;
@@ -32,7 +32,7 @@ class SettingsView extends GetWidget<SettingsController> {
Obx(() { Obx(() {
final labelVisibility = controller final labelVisibility = controller
.manageAccountDashboardController .manageAccountDashboardController
.isLabelVisibility .isLabelVisibilityEnabled
.value; .value;
final isLabelCapabilitySupported = controller final isLabelCapabilitySupported = controller
.manageAccountDashboardController .manageAccountDashboardController
@@ -55,7 +55,7 @@ class PreferencesView extends GetWidget<PreferencesController> with AppLoaderMix
Obx( Obx(
() { () {
final labelVisibility = controller final labelVisibility = controller
.accountDashboardController.isLabelVisibility.value; .accountDashboardController.isLabelVisibilityEnabled.value;
final isLabelCapabilitySupported = controller final isLabelCapabilitySupported = controller
.accountDashboardController .accountDashboardController
@@ -79,7 +79,7 @@ class PreferencesView extends GetWidget<PreferencesController> with AppLoaderMix
final localSettingOption = controller.localSettings.value; final localSettingOption = controller.localSettings.value;
final isLabelVisibility = controller final isLabelVisibility = controller
.accountDashboardController .accountDashboardController
.isLabelVisibility; .isLabelVisibilityEnabled;
if (settingOption == null && if (settingOption == null &&
localSettingOption.configs.isEmpty) { localSettingOption.configs.isEmpty) {