TF-296 Fix download file on browser

This commit is contained in:
dab246
2022-03-03 13:54:23 +07:00
committed by Dat H. Pham
parent a24a4a2bfd
commit 7beebfebc8
19 changed files with 221 additions and 32 deletions
@@ -27,6 +27,13 @@ abstract class EmailDataSource {
CancelToken cancelToken
);
Future<bool> downloadAttachmentForWeb(
Attachment attachment,
AccountId accountId,
String baseDownloadUrl,
AccountRequest accountRequest,
);
Future<List<EmailId>> moveToMailbox(AccountId accountId, MoveRequest moveRequest);
Future<List<Email>> markAsStar(
@@ -113,4 +113,13 @@ class EmailDataSourceImpl extends EmailDataSource {
throw error;
});
}
@override
Future<bool> downloadAttachmentForWeb(Attachment attachment, AccountId accountId, String baseDownloadUrl, AccountRequest accountRequest) {
return Future.sync(() async {
return await emailAPI.downloadAttachmentForWeb(attachment, accountId, baseDownloadUrl, accountRequest);
}).catchError((error) {
throw error;
});
}
}
@@ -202,6 +202,19 @@ class EmailAPI {
cancelToken: cancelToken);
}
Future<bool> downloadAttachmentForWeb(
Attachment attachment,
AccountId accountId,
String baseDownloadUrl,
AccountRequest accountRequest,
) async {
return _downloadManager.downloadFileForWeb(
attachment.getDownloadUrl(baseDownloadUrl, accountId),
attachment.name ?? '',
accountRequest.basicAuth,
);
}
Future<List<EmailId>> moveToMailbox(AccountId accountId, MoveRequest moveRequest) async {
final setEmailMethod = SetEmailMethod(accountId)
..addUpdates(moveRequest.emailIds
@@ -103,4 +103,9 @@ class EmailRepositoryImpl extends EmailRepository {
Future<Email?> updateEmailDrafts(AccountId accountId, Email newEmail, EmailId oldEmailId) {
return emailDataSource.updateEmailDrafts(accountId, newEmail, oldEmailId);
}
@override
Future<bool> downloadAttachmentForWeb(Attachment attachment, AccountId accountId, String baseDownloadUrl, AccountRequest accountRequest) {
return emailDataSource.downloadAttachmentForWeb(attachment, accountId, baseDownloadUrl, accountRequest);
}
}