diff --git a/lib/features/composer/data/datasource_impl/composer_datasource_impl.dart b/lib/features/composer/data/datasource_impl/composer_datasource_impl.dart index a609133da..f06177022 100644 --- a/lib/features/composer/data/datasource_impl/composer_datasource_impl.dart +++ b/lib/features/composer/data/datasource_impl/composer_datasource_impl.dart @@ -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 downloadImageAsBase64(String url, String cid, FileInfo fileInfo, {double? maxWidth, bool? compress}) { - return downloadClient.downloadImageAsBase64( + Future 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); + }); } } \ No newline at end of file diff --git a/lib/features/composer/presentation/composer_bindings.dart b/lib/features/composer/presentation/composer_bindings.dart index 1c63e33af..7615704c9 100644 --- a/lib/features/composer/presentation/composer_bindings.dart +++ b/lib/features/composer/presentation/composer_bindings.dart @@ -69,7 +69,7 @@ class ComposerBindings extends BaseBindings { @override void bindingsDataSourceImpl() { Get.lazyPut(() => AttachmentUploadDataSourceImpl(Get.find())); - Get.lazyPut(() => ComposerDataSourceImpl(Get.find())); + Get.lazyPut(() => ComposerDataSourceImpl(Get.find(), Get.find())); Get.lazyPut(() => ContactDataSourceImpl()); Get.lazyPut(() => MailboxDataSourceImpl( Get.find(),