TF-1115 Implement catch exception for ContactDataSource
This commit is contained in:
@@ -22,7 +22,7 @@ class ComposerDataSourceImpl extends ComposerDataSource {
|
||||
}
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return downloadClient.downloadImageAsBase64(
|
||||
return await downloadClient.downloadImageAsBase64(
|
||||
url,
|
||||
cid,
|
||||
fileInfo.fileExtension,
|
||||
|
||||
@@ -3,21 +3,31 @@ import 'package:contacts_service/contacts_service.dart' as contact_service;
|
||||
import 'package:get/get.dart';
|
||||
import 'package:model/model.dart';
|
||||
import 'package:tmail_ui_user/features/composer/data/datasource/contact_datasource.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||
|
||||
class ContactDataSourceImpl extends ContactDataSource {
|
||||
|
||||
final ExceptionThrower _exceptionThrower;
|
||||
|
||||
ContactDataSourceImpl(this._exceptionThrower);
|
||||
|
||||
@override
|
||||
Future<List<Contact>> getContactSuggestions(AutoCompletePattern autoCompletePattern) async {
|
||||
if (autoCompletePattern.word.isEmpty) {
|
||||
return <DeviceContact>[];
|
||||
} else {
|
||||
final suggestedList = await contact_service.ContactsService
|
||||
return Future.sync(() async {
|
||||
if (autoCompletePattern.word.isEmpty) {
|
||||
return <DeviceContact>[];
|
||||
} else {
|
||||
final suggestedList = await contact_service.ContactsService
|
||||
.getContactsByEmailOrName(autoCompletePattern.word);
|
||||
if (suggestedList.isNotEmpty) {
|
||||
return suggestedList.expand((contact) => _toDeviceContact(contact)).toList();
|
||||
if (suggestedList.isNotEmpty) {
|
||||
return suggestedList.expand((contact) => _toDeviceContact(contact)).toList();
|
||||
} else {
|
||||
return <DeviceContact>[];
|
||||
}
|
||||
}
|
||||
return <DeviceContact>[];
|
||||
}
|
||||
}).catchError((error) {
|
||||
_exceptionThrower.throwException(error);
|
||||
});
|
||||
}
|
||||
|
||||
List<DeviceContact> _toDeviceContact(contact_service.Contact contact) {
|
||||
|
||||
Reference in New Issue
Block a user