TF-3488 Add hide download taskbar feature

This commit is contained in:
DatDang
2025-02-14 14:43:42 +07:00
committed by Dat H. Pham
parent d51f06f6f0
commit ca3905cb7a
10 changed files with 122 additions and 67 deletions
@@ -1,6 +1,7 @@
import 'dart:typed_data';
import 'package:core/presentation/state/failure.dart';
import 'package:core/presentation/state/success.dart';
import 'package:dio/dio.dart';
import 'package:model/download/download_task_id.dart';
import 'package:model/email/attachment.dart';
@@ -10,11 +11,12 @@ class StartDownloadAttachmentForWeb extends UIState {
final DownloadTaskId taskId;
final Attachment attachment;
final CancelToken? cancelToken;
StartDownloadAttachmentForWeb(this.taskId, this.attachment);
StartDownloadAttachmentForWeb(this.taskId, this.attachment, [this.cancelToken]);
@override
List<Object> get props => [taskId, attachment];
List<Object?> get props => [taskId, attachment, cancelToken];
}
class DownloadingAttachmentForWeb extends UIState {
@@ -59,13 +61,15 @@ class DownloadAttachmentForWebFailure extends FeatureFailure {
final DownloadTaskId? taskId;
final Attachment? attachment;
final CancelToken? cancelToken;
DownloadAttachmentForWebFailure({
this.attachment,
this.taskId,
dynamic exception
}) : super(exception: exception);
this.cancelToken,
super.exception
});
@override
List<Object?> get props => [attachment, taskId, ...super.props];
List<Object?> get props => [attachment, taskId, cancelToken, ...super.props];
}
@@ -38,8 +38,8 @@ class DownloadAttachmentForWebInteractor {
{CancelToken? cancelToken}
) async* {
try {
yield Right<Failure, Success>(StartDownloadAttachmentForWeb(taskId, attachment));
onReceiveController.add(Right(StartDownloadAttachmentForWeb(taskId, attachment)));
yield Right<Failure, Success>(StartDownloadAttachmentForWeb(taskId, attachment, cancelToken));
onReceiveController.add(Right(StartDownloadAttachmentForWeb(taskId, attachment, cancelToken)));
final currentAccount = await _accountRepository.getCurrentAccount();
AccountRequest? accountRequest;
@@ -77,7 +77,8 @@ class DownloadAttachmentForWebInteractor {
DownloadAttachmentForWebFailure(
attachment: attachment,
taskId: taskId,
exception: exception
exception: exception,
cancelToken: cancelToken,
)
);
}