TF-2764 Remove ViewAttachmentForWebInteractor

This commit is contained in:
dab246
2024-05-17 02:19:22 +07:00
committed by Dat H. Pham
parent 7524a97bc8
commit 450e0eb2ab
7 changed files with 52 additions and 483 deletions
@@ -1,29 +0,0 @@
import 'package:tmail_ui_user/features/email/domain/state/download_attachment_for_web_state.dart';
class IdleViewAttachmentForWeb extends IdleDownloadAttachmentForWeb {}
class StartViewAttachmentForWeb extends StartDownloadAttachmentForWeb {
StartViewAttachmentForWeb(super.taskId, super.attachment);
}
class ViewingAttachmentForWeb extends DownloadingAttachmentForWeb {
ViewingAttachmentForWeb(
super.taskId,
super.attachment,
super.progress,
super.downloaded,
super.total,
);
}
class ViewAttachmentForWebSuccess extends DownloadAttachmentForWebSuccess {
ViewAttachmentForWebSuccess(super.taskId, super.attachment, super.bytes);
}
class ViewAttachmentForWebFailure extends DownloadAttachmentForWebFailure {
ViewAttachmentForWebFailure({
required super.attachment,
super.taskId,
super.exception,
});
}
@@ -1,75 +0,0 @@
import 'dart:async';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:dartz/dartz.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:model/download/download_task_id.dart';
import 'package:model/email/attachment.dart';
import 'package:tmail_ui_user/features/email/domain/state/download_attachment_for_web_state.dart';
import 'package:tmail_ui_user/features/email/domain/state/view_attachment_for_web_state.dart';
import 'package:tmail_ui_user/features/email/domain/usecases/download_attachment_for_web_interactor.dart';
class ViewAttachmentForWebInteractor {
ViewAttachmentForWebInteractor(this._downloadAttachmentForWebInteractor);
final DownloadAttachmentForWebInteractor _downloadAttachmentForWebInteractor;
Stream<Either<Failure, Success>> execute(
DownloadTaskId taskId,
Attachment attachment,
AccountId accountId,
String baseDownloadUrl,
StreamController<Either<Failure, Success>> onReceiveController,
) =>
_downloadAttachmentForWebInteractor
.execute(
taskId,
attachment,
accountId,
baseDownloadUrl,
onReceiveController)
.map(
(result) => result.fold(
(failure) {
if (failure is DownloadAttachmentForWebFailure) {
return Left(ViewAttachmentForWebFailure(
attachment: attachment,
taskId: failure.taskId,
exception: failure.exception,
));
}
return Left(failure);
},
(success) {
if (success is StartDownloadAttachmentForWeb) {
return Right(StartViewAttachmentForWeb(
success.taskId,
success.attachment,
));
}
if (success is DownloadingAttachmentForWeb) {
return Right(ViewingAttachmentForWeb(
success.taskId,
success.attachment,
success.progress,
success.downloaded,
success.total,
));
}
if (success is DownloadAttachmentForWebSuccess) {
return Right(ViewAttachmentForWebSuccess(
success.taskId,
success.attachment,
success.bytes,
));
}
return Right(success);
},
),
);
}