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