TF-1115 Implement catch exception when for GetAllEmail and RefreshChangesEmail
This commit is contained in:
@@ -77,7 +77,7 @@ packages:
|
||||
name: build_runner_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.2.6"
|
||||
version: "7.2.7"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -91,7 +91,7 @@ packages:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -365,7 +365,7 @@ packages:
|
||||
name: graphs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -420,7 +420,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: ab07a8a03d63e20f6ea5e62bcc1ca8cdc1fd93ff
|
||||
resolved-ref: "45ea109f70be0d868b005aadf11a39e2ac816c38"
|
||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@@ -631,7 +631,7 @@ packages:
|
||||
name: sqflite_common
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "2.4.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -729,7 +729,7 @@ packages:
|
||||
name: url_launcher_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.19"
|
||||
version: "6.0.20"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -77,7 +77,7 @@ packages:
|
||||
name: build_runner_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.2.6"
|
||||
version: "7.2.7"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -91,7 +91,7 @@ packages:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -234,7 +234,7 @@ packages:
|
||||
name: graphs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
http_mock_adapter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -268,7 +268,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: ab07a8a03d63e20f6ea5e62bcc1ca8cdc1fd93ff
|
||||
resolved-ref: "45ea109f70be0d868b005aadf11a39e2ac816c38"
|
||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:contact/contact/model/capability_contact.dart';
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||
@@ -12,18 +14,30 @@ import 'package:tmail_ui_user/features/email/presentation/mdn_interactor_binding
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/contact_autocomplete_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/tmail_autocomplete_bindings.dart';
|
||||
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
|
||||
abstract class BaseController extends GetxController
|
||||
with MessageDialogActionMixin,
|
||||
PopupContextMenuActionMixin,
|
||||
ViewAsDialogActionMixin {
|
||||
|
||||
final _appToast = Get.find<AppToast>();
|
||||
final _imagePaths = Get.find<ImagePaths>();
|
||||
final _responsiveUtils = Get.find<ResponsiveUtils>();
|
||||
|
||||
final viewState = Rx<Either<Failure, Success>>(Right(UIState.idle));
|
||||
FpsCallback? fpsCallback;
|
||||
|
||||
void consumeState(Stream<Either<Failure, Success>> newStateStream) async {
|
||||
newStateStream.listen(
|
||||
(state) => onData(state),
|
||||
onError: (error) => onError(error),
|
||||
onError: (error, stackTrace) {
|
||||
logError('BaseController::consumeState():onError:error: $error');
|
||||
logError('BaseController::consumeState():onError:stackTrace: $stackTrace');
|
||||
onError(error);
|
||||
},
|
||||
onDone: () => onDone()
|
||||
);
|
||||
}
|
||||
@@ -48,7 +62,34 @@ abstract class BaseController extends GetxController
|
||||
viewState.value = newState;
|
||||
}
|
||||
|
||||
void onError(dynamic error);
|
||||
void onError(dynamic error) {
|
||||
String messageError = '';
|
||||
if (error is MethodLevelErrors) {
|
||||
messageError = error.message ?? error.type.value;
|
||||
} else {
|
||||
if (currentContext != null) {
|
||||
messageError = AppLocalizations
|
||||
.of(currentContext!)
|
||||
.unknown_error_login_message;
|
||||
}
|
||||
}
|
||||
|
||||
if (messageError.isNotEmpty && currentContext != null && currentOverlayContext != null) {
|
||||
_appToast.showBottomToast(
|
||||
currentOverlayContext!,
|
||||
messageError,
|
||||
leadingIcon: SvgPicture.asset(
|
||||
_imagePaths.icNotConnection,
|
||||
width: 24,
|
||||
height: 24,
|
||||
color: Colors.white,
|
||||
fit: BoxFit.fill),
|
||||
backgroundColor: AppColor.toastErrorBackgroundColor,
|
||||
textColor: Colors.white,
|
||||
textActionColor: Colors.white,
|
||||
maxWidth: _responsiveUtils.getMaxWidthToast(currentContext!));
|
||||
}
|
||||
}
|
||||
|
||||
void onDone();
|
||||
|
||||
|
||||
@@ -5,6 +5,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/mailbox/data/model/state_type.dart';
|
||||
|
||||
class CachingManager {
|
||||
|
||||
@@ -41,4 +42,11 @@ class CachingManager {
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> cleanEmailCache() async {
|
||||
await Future.wait([
|
||||
_stateCacheClient.deleteItem(StateType.email.value),
|
||||
_emailCacheClient.clearAllData(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,19 @@ import 'package:tmail_ui_user/features/thread/data/network/thread_isolate_worker
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||
import 'package:tmail_ui_user/features/thread/data/network/thread_api.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
|
||||
final ThreadAPI threadAPI;
|
||||
final ThreadIsolateWorker _threadIsolateWorker;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
ThreadDataSourceImpl(this.threadAPI, this._threadIsolateWorker);
|
||||
ThreadDataSourceImpl(
|
||||
this.threadAPI,
|
||||
this._threadIsolateWorker,
|
||||
this._exceptionThrower
|
||||
);
|
||||
|
||||
@override
|
||||
Future<EmailsResponse> getAllEmail(
|
||||
@@ -40,7 +46,7 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
filter: filter,
|
||||
properties: properties);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,7 +66,7 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
||||
propertiesCreated: propertiesCreated,
|
||||
propertiesUpdated: propertiesUpdated);
|
||||
}).catchError((error) {
|
||||
throw error;
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
||||
import 'package:tmail_ui_user/features/caching/state_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/email/data/datasource/email_datasource.dart';
|
||||
import 'package:tmail_ui_user/features/email/data/datasource/html_datasource.dart';
|
||||
@@ -42,6 +43,7 @@ import 'package:tmail_ui_user/features/thread/domain/usecases/refresh_changes_em
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/search_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/domain/usecases/search_more_email_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/thread_controller.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
|
||||
class ThreadBindings extends BaseBindings {
|
||||
|
||||
@@ -61,6 +63,7 @@ class ThreadBindings extends BaseBindings {
|
||||
Get.find<EmptyTrashFolderInteractor>(),
|
||||
Get.find<MarkAsEmailReadInteractor>(),
|
||||
Get.find<MoveToMailboxInteractor>(),
|
||||
Get.find<CachingManager>(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -77,7 +80,10 @@ class ThreadBindings extends BaseBindings {
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => MailboxDataSourceImpl(Get.find<MailboxAPI>(), Get.find<MailboxIsolateWorker>()));
|
||||
Get.lazyPut(() => MailboxCacheDataSourceImpl(Get.find<MailboxCacheManager>()));
|
||||
Get.lazyPut(() => ThreadDataSourceImpl(Get.find<ThreadAPI>(), Get.find<ThreadIsolateWorker>()));
|
||||
Get.lazyPut(() => ThreadDataSourceImpl(
|
||||
Get.find<ThreadAPI>(),
|
||||
Get.find<ThreadIsolateWorker>(),
|
||||
Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
|
||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>()));
|
||||
Get.lazyPut(() => EmailDataSourceImpl(Get.find<EmailAPI>()));
|
||||
|
||||
@@ -17,6 +17,7 @@ import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||
import 'package:tmail_ui_user/features/base/base_controller.dart';
|
||||
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/save_email_as_drafts_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/send_email_state.dart';
|
||||
import 'package:tmail_ui_user/features/composer/domain/state/update_email_drafts_state.dart';
|
||||
@@ -71,6 +72,7 @@ import 'package:tmail_ui_user/features/thread/domain/usecases/search_more_email_
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/delete_action_type.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_state.dart';
|
||||
import 'package:tmail_ui_user/features/thread/presentation/model/search_status.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
@@ -95,6 +97,7 @@ class ThreadController extends BaseController {
|
||||
final EmptyTrashFolderInteractor _emptyTrashFolderInteractor;
|
||||
final MarkAsEmailReadInteractor _markAsEmailReadInteractor;
|
||||
final MoveToMailboxInteractor _moveToMailboxInteractor;
|
||||
final CachingManager _cachingManager;
|
||||
|
||||
final emailList = <PresentationEmail>[].obs;
|
||||
final listEmailDrag = <PresentationEmail>[].obs;
|
||||
@@ -139,6 +142,7 @@ class ThreadController extends BaseController {
|
||||
this._emptyTrashFolderInteractor,
|
||||
this._markAsEmailReadInteractor,
|
||||
this._moveToMailboxInteractor,
|
||||
this._cachingManager,
|
||||
);
|
||||
|
||||
@override
|
||||
@@ -199,8 +203,6 @@ class ThreadController extends BaseController {
|
||||
} else if (failure is MarkAsStarMultipleEmailAllFailure
|
||||
|| failure is MarkAsStarMultipleEmailFailure) {
|
||||
_markAsStarMultipleEmailFailure(failure);
|
||||
} else if (failure is LoadMoreEmailsFailure) {
|
||||
stopFpsMeter();
|
||||
}
|
||||
},
|
||||
(success) {
|
||||
@@ -224,15 +226,15 @@ class ThreadController extends BaseController {
|
||||
_markAsEmailReadSuccess(success);
|
||||
} else if (success is MoveToMailboxSuccess) {
|
||||
_moveToMailboxSuccess(success);
|
||||
} else if (success is LoadMoreEmailsSuccess) {
|
||||
stopFpsMeter();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void onError(error) {}
|
||||
void onError(error) {
|
||||
_handleErrorGetAllOrRefreshChangesEmail(error);
|
||||
}
|
||||
|
||||
void _initWorker() {
|
||||
mailboxWorker = ever(mailboxDashBoardController.selectedMailbox, (mailbox) {
|
||||
@@ -345,6 +347,16 @@ class ThreadController extends BaseController {
|
||||
viewStateWorker.call();
|
||||
}
|
||||
|
||||
void _handleErrorGetAllOrRefreshChangesEmail(dynamic error) async {
|
||||
logError('ThreadController::_handleErrorGetAllOrRefreshChangesEmail():Error: $error');
|
||||
if (error is CannotCalculateChangesMethodResponseException) {
|
||||
await _cachingManager.cleanEmailCache();
|
||||
_getAllEmail();
|
||||
} else {
|
||||
super.onError(error);
|
||||
}
|
||||
}
|
||||
|
||||
void _getAllEmail() {
|
||||
if (_accountId != null) {
|
||||
_getAllEmailAction(_accountId!, mailboxId: _currentMailboxId);
|
||||
@@ -427,10 +439,7 @@ class ThreadController extends BaseController {
|
||||
dispatchState(Right(LoadingState()));
|
||||
canLoadMore = true;
|
||||
cancelSelectEmail();
|
||||
|
||||
if (_accountId != null) {
|
||||
_getAllEmail();
|
||||
}
|
||||
_getAllEmail();
|
||||
}
|
||||
|
||||
void _refreshEmailChanges({jmap.State? currentEmailState}) {
|
||||
|
||||
+6
-6
@@ -77,7 +77,7 @@ packages:
|
||||
name: build_runner_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.2.6"
|
||||
version: "7.2.7"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -91,7 +91,7 @@ packages:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -372,7 +372,7 @@ packages:
|
||||
name: graphs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
html:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -420,7 +420,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: ab07a8a03d63e20f6ea5e62bcc1ca8cdc1fd93ff
|
||||
resolved-ref: "45ea109f70be0d868b005aadf11a39e2ac816c38"
|
||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@@ -617,7 +617,7 @@ packages:
|
||||
name: sqflite_common
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "2.4.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -715,7 +715,7 @@ packages:
|
||||
name: url_launcher_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.19"
|
||||
version: "6.0.20"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
+7
-7
@@ -91,7 +91,7 @@ packages:
|
||||
name: build_runner_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.2.6"
|
||||
version: "7.2.7"
|
||||
built_collection:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -105,7 +105,7 @@ packages:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
byte_converter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -658,7 +658,7 @@ packages:
|
||||
name: graphs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
hive:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -757,7 +757,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: ab07a8a03d63e20f6ea5e62bcc1ca8cdc1fd93ff
|
||||
resolved-ref: "45ea109f70be0d868b005aadf11a39e2ac816c38"
|
||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
@@ -1231,7 +1231,7 @@ packages:
|
||||
name: sqflite_common
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "2.4.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1273,7 +1273,7 @@ packages:
|
||||
name: syncfusion_flutter_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "20.3.50"
|
||||
version: "20.3.52"
|
||||
syncfusion_flutter_datepicker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1364,7 +1364,7 @@ packages:
|
||||
name: url_launcher_android
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.0.19"
|
||||
version: "6.0.20"
|
||||
url_launcher_ios:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -77,7 +77,7 @@ packages:
|
||||
name: build_runner_core
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "7.2.6"
|
||||
version: "7.2.7"
|
||||
built_collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -91,7 +91,7 @@ packages:
|
||||
name: built_value
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "8.4.1"
|
||||
version: "8.4.2"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -234,7 +234,7 @@ packages:
|
||||
name: graphs
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
version: "2.2.0"
|
||||
http_mock_adapter:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -268,7 +268,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: ab07a8a03d63e20f6ea5e62bcc1ca8cdc1fd93ff
|
||||
resolved-ref: "45ea109f70be0d868b005aadf11a39e2ac816c38"
|
||||
url: "https://github.com/linagora/jmap-dart-client.git"
|
||||
source: git
|
||||
version: "0.0.1"
|
||||
|
||||
Reference in New Issue
Block a user