TF-1115 Implement catch exception for ThreadDataSource
This commit is contained in:
+1
-1
@@ -157,7 +157,7 @@ class MailboxDashBoardBindings extends BaseBindings {
|
|||||||
Get.find<ThreadAPI>(),
|
Get.find<ThreadAPI>(),
|
||||||
Get.find<ThreadIsolateWorker>(),
|
Get.find<ThreadIsolateWorker>(),
|
||||||
Get.find<RemoteExceptionThrower>()));
|
Get.find<RemoteExceptionThrower>()));
|
||||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
|
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>(), Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
|
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => MailboxDataSourceImpl(
|
Get.lazyPut(() => MailboxDataSourceImpl(
|
||||||
Get.find<MailboxAPI>(),
|
Get.find<MailboxAPI>(),
|
||||||
|
|||||||
@@ -13,12 +13,14 @@ import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dar
|
|||||||
import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart';
|
import 'package:tmail_ui_user/features/thread/data/model/email_change_response.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/email_response.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.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 LocalThreadDataSourceImpl extends ThreadDataSource {
|
class LocalThreadDataSourceImpl extends ThreadDataSource {
|
||||||
|
|
||||||
final EmailCacheManager _emailCacheManager;
|
final EmailCacheManager _emailCacheManager;
|
||||||
|
final ExceptionThrower _exceptionThrower;
|
||||||
|
|
||||||
LocalThreadDataSourceImpl(this._emailCacheManager);
|
LocalThreadDataSourceImpl(this._emailCacheManager, this._exceptionThrower);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<EmailsResponse> getAllEmail(
|
Future<EmailsResponse> getAllEmail(
|
||||||
@@ -46,20 +48,36 @@ class LocalThreadDataSourceImpl extends ThreadDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<Email>> getAllEmailCache({MailboxId? inMailboxId, Set<Comparator>? sort, FilterMessageOption? filterOption, UnsignedInt? limit}) {
|
Future<List<Email>> getAllEmailCache({
|
||||||
|
MailboxId? inMailboxId,
|
||||||
|
Set<Comparator>? sort,
|
||||||
|
FilterMessageOption? filterOption,
|
||||||
|
UnsignedInt? limit
|
||||||
|
}) {
|
||||||
return Future.sync(() async {
|
return Future.sync(() async {
|
||||||
return await _emailCacheManager.getAllEmail(inMailboxId: inMailboxId, sort: sort, filterOption: filterOption ?? FilterMessageOption.all, limit: limit);
|
return await _emailCacheManager.getAllEmail(
|
||||||
|
inMailboxId: inMailboxId,
|
||||||
|
sort: sort,
|
||||||
|
filterOption: filterOption ?? FilterMessageOption.all,
|
||||||
|
limit: limit);
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
throw error;
|
_exceptionThrower.throwException(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> update({List<Email>? updated, List<Email>? created, List<EmailId>? destroyed}) {
|
Future<void> update({
|
||||||
|
List<Email>? updated,
|
||||||
|
List<Email>? created,
|
||||||
|
List<EmailId>? destroyed
|
||||||
|
}) {
|
||||||
return Future.sync(() async {
|
return Future.sync(() async {
|
||||||
return await _emailCacheManager.update(updated: updated, created: created, destroyed: destroyed);
|
return await _emailCacheManager.update(
|
||||||
|
updated: updated,
|
||||||
|
created: created,
|
||||||
|
destroyed: destroyed);
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
throw error;
|
_exceptionThrower.throwException(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class ThreadDataSourceImpl extends ThreadDataSource {
|
|||||||
updateDestroyedEmailCache,
|
updateDestroyedEmailCache,
|
||||||
);
|
);
|
||||||
}).catchError((error) {
|
}).catchError((error) {
|
||||||
throw error;
|
_exceptionThrower.throwException(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ class ThreadBindings extends BaseBindings {
|
|||||||
Get.find<ThreadAPI>(),
|
Get.find<ThreadAPI>(),
|
||||||
Get.find<ThreadIsolateWorker>(),
|
Get.find<ThreadIsolateWorker>(),
|
||||||
Get.find<RemoteExceptionThrower>()));
|
Get.find<RemoteExceptionThrower>()));
|
||||||
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>()));
|
Get.lazyPut(() => LocalThreadDataSourceImpl(Get.find<EmailCacheManager>(), Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
|
Get.lazyPut(() => StateDataSourceImpl(Get.find<StateCacheClient>(), Get.find<CacheExceptionThrower>()));
|
||||||
Get.lazyPut(() => EmailDataSourceImpl(
|
Get.lazyPut(() => EmailDataSourceImpl(
|
||||||
Get.find<EmailAPI>(),
|
Get.find<EmailAPI>(),
|
||||||
|
|||||||
Reference in New Issue
Block a user