TF-4128 Separate download handling into independent class to decouple from views on web

This commit is contained in:
dab246
2025-10-28 16:44:40 +07:00
committed by Dat H. Pham
parent 832f8e1391
commit be8eaf6258
37 changed files with 955 additions and 1095 deletions
@@ -1,10 +1,6 @@
import 'dart:async';
import 'dart:typed_data';
import 'package:core/data/network/download/downloaded_response.dart';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart';
import 'package:dio/dio.dart';
import 'package:email_recovery/email_recovery/email_recovery_action.dart';
import 'package:email_recovery/email_recovery/email_recovery_action_id.dart';
@@ -16,7 +12,6 @@ import 'package:jmap_dart_client/jmap/core/session/session.dart';
import 'package:jmap_dart_client/jmap/core/user_name.dart';
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
import 'package:model/account/account_request.dart';
import 'package:model/download/download_task_id.dart';
import 'package:model/email/attachment.dart';
import 'package:model/email/mark_star_action.dart';
import 'package:model/email/read_actions.dart';
@@ -57,13 +52,6 @@ abstract class EmailDataSource {
ReadActions readActions,
);
Future<List<DownloadTaskId>> downloadAttachments(
List<Attachment> attachments,
AccountId accountId,
String baseDownloadUrl,
AccountRequest accountRequest
);
Future<DownloadedResponse> exportAttachment(
Attachment attachment,
AccountId accountId,
@@ -72,16 +60,6 @@ abstract class EmailDataSource {
CancelToken cancelToken
);
Future<Uint8List> downloadAttachmentForWeb(
DownloadTaskId taskId,
Attachment attachment,
AccountId accountId,
String baseDownloadUrl,
AccountRequest accountRequest,
StreamController<Either<Failure, Success>> onReceiveController,
{CancelToken? cancelToken}
);
Future<({
List<EmailId> emailIdsSuccess,
Map<Id, SetError> mapErrors,
@@ -149,6 +127,7 @@ abstract class EmailDataSource {
AccountId accountId,
List<EmailId> emailIds,
);
Future<bool> deleteEmailPermanently(
Session session,
AccountId accountId,
@@ -214,17 +193,6 @@ abstract class EmailDataSource {
Future<EMLPreviewer> getPreviewEMLContentInMemory(String keyStored);
Future<void> downloadAllAttachmentsForWeb(
AccountId accountId,
EmailId emailId,
String baseDownloadAllUrl,
String outputFileName,
AccountRequest accountRequest,
DownloadTaskId taskId,
StreamController<Either<Failure, Success>> onReceiveController,
{CancelToken? cancelToken}
);
Future<DownloadedResponse> exportAllAttachments(
AccountId accountId,
EmailId emailId,