TF-1115 Implement catch exception for ComposerDataSource
This commit is contained in:
@@ -2,16 +2,27 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:model/upload/file_info.dart';
|
||||
import 'package:tmail_ui_user/features/composer/data/datasource/composer_datasource.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class ComposerDataSourceImpl extends ComposerDataSource {
|
||||
|
||||
final DownloadClient downloadClient;
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
ComposerDataSourceImpl(this.downloadClient);
|
||||
ComposerDataSourceImpl(this.downloadClient, this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<String?> downloadImageAsBase64(String url, String cid, FileInfo fileInfo, {double? maxWidth, bool? compress}) {
|
||||
return downloadClient.downloadImageAsBase64(
|
||||
Future<String?> downloadImageAsBase64(
|
||||
String url,
|
||||
String cid,
|
||||
FileInfo fileInfo,
|
||||
{
|
||||
double? maxWidth,
|
||||
bool? compress
|
||||
}
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return downloadClient.downloadImageAsBase64(
|
||||
url,
|
||||
cid,
|
||||
fileInfo.fileExtension,
|
||||
@@ -19,5 +30,8 @@ class ComposerDataSourceImpl extends ComposerDataSource {
|
||||
bytesData: fileInfo.bytes,
|
||||
maxWidth: maxWidth,
|
||||
compress: compress);
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class ComposerBindings extends BaseBindings {
|
||||
@override
|
||||
void bindingsDataSourceImpl() {
|
||||
Get.lazyPut(() => AttachmentUploadDataSourceImpl(Get.find<FileUploader>()));
|
||||
Get.lazyPut(() => ComposerDataSourceImpl(Get.find<DownloadClient>()));
|
||||
Get.lazyPut(() => ComposerDataSourceImpl(Get.find<DownloadClient>(), Get.find<RemoteExceptionThrower>()));
|
||||
Get.lazyPut(() => ContactDataSourceImpl());
|
||||
Get.lazyPut(() => MailboxDataSourceImpl(
|
||||
Get.find<MailboxAPI>(),
|
||||
|
||||
Reference in New Issue
Block a user