TF-2764 Add CancelToken to download attachment for web
This commit is contained in:
@@ -58,7 +58,8 @@ abstract class EmailDataSource {
|
|||||||
AccountId accountId,
|
AccountId accountId,
|
||||||
String baseDownloadUrl,
|
String baseDownloadUrl,
|
||||||
AccountRequest accountRequest,
|
AccountRequest accountRequest,
|
||||||
StreamController<Either<Failure, Success>> onReceiveController
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<List<EmailId>> moveToMailbox(Session session, AccountId accountId, MoveToMailboxRequest moveRequest);
|
Future<List<EmailId>> moveToMailbox(Session session, AccountId accountId, MoveToMailboxRequest moveRequest);
|
||||||
|
|||||||
@@ -134,7 +134,8 @@ class EmailDataSourceImpl extends EmailDataSource {
|
|||||||
AccountId accountId,
|
AccountId accountId,
|
||||||
String baseDownloadUrl,
|
String baseDownloadUrl,
|
||||||
AccountRequest accountRequest,
|
AccountRequest accountRequest,
|
||||||
StreamController<Either<Failure, Success>> onReceiveController
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
) {
|
) {
|
||||||
return Future.sync(() async {
|
return Future.sync(() async {
|
||||||
return await emailAPI.downloadAttachmentForWeb(
|
return await emailAPI.downloadAttachmentForWeb(
|
||||||
@@ -143,7 +144,8 @@ class EmailDataSourceImpl extends EmailDataSource {
|
|||||||
accountId,
|
accountId,
|
||||||
baseDownloadUrl,
|
baseDownloadUrl,
|
||||||
accountRequest,
|
accountRequest,
|
||||||
onReceiveController);
|
onReceiveController,
|
||||||
|
cancelToken: cancelToken);
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,15 @@ class EmailHiveCacheDataSourceImpl extends EmailDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Uint8List> downloadAttachmentForWeb(DownloadTaskId taskId, Attachment attachment, AccountId accountId, String baseDownloadUrl, AccountRequest accountRequest, StreamController<Either<Failure, Success>> onReceiveController) {
|
Future<Uint8List> downloadAttachmentForWeb(
|
||||||
|
DownloadTaskId taskId,
|
||||||
|
Attachment attachment,
|
||||||
|
AccountId accountId,
|
||||||
|
String baseDownloadUrl,
|
||||||
|
AccountRequest accountRequest,
|
||||||
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
|
) {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -336,6 +336,7 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
String baseDownloadUrl,
|
String baseDownloadUrl,
|
||||||
AccountRequest accountRequest,
|
AccountRequest accountRequest,
|
||||||
StreamController<Either<Failure, Success>> onReceiveController,
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
) async {
|
) async {
|
||||||
final authentication = accountRequest.authenticationType == AuthenticationType.oidc
|
final authentication = accountRequest.authenticationType == AuthenticationType.oidc
|
||||||
? accountRequest.bearerToken
|
? accountRequest.bearerToken
|
||||||
@@ -352,6 +353,7 @@ class EmailAPI with HandleSetErrorMixin {
|
|||||||
options: Options(
|
options: Options(
|
||||||
headers: headerParam,
|
headers: headerParam,
|
||||||
responseType: ResponseType.bytes),
|
responseType: ResponseType.bytes),
|
||||||
|
cancelToken: cancelToken,
|
||||||
onReceiveProgress: (downloaded, total) {
|
onReceiveProgress: (downloaded, total) {
|
||||||
log('EmailAPI::downloadFileForWeb(): downloaded = $downloaded | total: $total');
|
log('EmailAPI::downloadFileForWeb(): downloaded = $downloaded | total: $total');
|
||||||
double progress = 0;
|
double progress = 0;
|
||||||
|
|||||||
@@ -153,7 +153,8 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
AccountId accountId,
|
AccountId accountId,
|
||||||
String baseDownloadUrl,
|
String baseDownloadUrl,
|
||||||
AccountRequest accountRequest,
|
AccountRequest accountRequest,
|
||||||
StreamController<Either<Failure, Success>> onReceiveController
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
) {
|
) {
|
||||||
return emailDataSource[DataSourceType.network]!.downloadAttachmentForWeb(
|
return emailDataSource[DataSourceType.network]!.downloadAttachmentForWeb(
|
||||||
taskId,
|
taskId,
|
||||||
@@ -161,7 +162,8 @@ class EmailRepositoryImpl extends EmailRepository {
|
|||||||
accountId,
|
accountId,
|
||||||
baseDownloadUrl,
|
baseDownloadUrl,
|
||||||
accountRequest,
|
accountRequest,
|
||||||
onReceiveController);
|
onReceiveController,
|
||||||
|
cancelToken: cancelToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ abstract class EmailRepository {
|
|||||||
AccountId accountId,
|
AccountId accountId,
|
||||||
String baseDownloadUrl,
|
String baseDownloadUrl,
|
||||||
AccountRequest accountRequest,
|
AccountRequest accountRequest,
|
||||||
StreamController<Either<Failure, Success>> onReceiveController
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<List<EmailId>> moveToMailbox(Session session, AccountId accountId, MoveToMailboxRequest moveRequest);
|
Future<List<EmailId>> moveToMailbox(Session session, AccountId accountId, MoveToMailboxRequest moveRequest);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
import 'package:core/presentation/state/failure.dart';
|
import 'package:core/presentation/state/failure.dart';
|
||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
||||||
import 'package:model/account/account_request.dart';
|
import 'package:model/account/account_request.dart';
|
||||||
@@ -33,7 +34,8 @@ class DownloadAttachmentForWebInteractor {
|
|||||||
Attachment attachment,
|
Attachment attachment,
|
||||||
AccountId accountId,
|
AccountId accountId,
|
||||||
String baseDownloadUrl,
|
String baseDownloadUrl,
|
||||||
StreamController<Either<Failure, Success>> onReceiveController
|
StreamController<Either<Failure, Success>> onReceiveController,
|
||||||
|
{CancelToken? cancelToken}
|
||||||
) async* {
|
) async* {
|
||||||
try {
|
try {
|
||||||
yield Right<Failure, Success>(StartDownloadAttachmentForWeb(taskId, attachment));
|
yield Right<Failure, Success>(StartDownloadAttachmentForWeb(taskId, attachment));
|
||||||
@@ -59,7 +61,8 @@ class DownloadAttachmentForWebInteractor {
|
|||||||
accountId,
|
accountId,
|
||||||
baseDownloadUrl,
|
baseDownloadUrl,
|
||||||
accountRequest,
|
accountRequest,
|
||||||
onReceiveController
|
onReceiveController,
|
||||||
|
cancelToken: cancelToken
|
||||||
);
|
);
|
||||||
|
|
||||||
yield Right<Failure, Success>(
|
yield Right<Failure, Success>(
|
||||||
|
|||||||
Reference in New Issue
Block a user