Fix do not show session expires dialog when add inline image & attachment
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -24,6 +24,7 @@ class AttachmentUploadDataSourceImpl extends AttachmentUploadDataSource {
|
|||||||
fileInfo,
|
fileInfo,
|
||||||
uploadUri,
|
uploadUri,
|
||||||
_fileUploader,
|
_fileUploader,
|
||||||
|
_exceptionThrower,
|
||||||
cancelToken: cancelToken
|
cancelToken: cancelToken
|
||||||
)..upload();
|
)..upload();
|
||||||
}).catchError(_exceptionThrower.throwException);
|
}).catchError(_exceptionThrower.throwException);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import 'package:model/upload/file_info.dart';
|
|||||||
import 'package:tmail_ui_user/features/upload/data/network/file_uploader.dart';
|
import 'package:tmail_ui_user/features/upload/data/network/file_uploader.dart';
|
||||||
import 'package:tmail_ui_user/features/upload/domain/model/upload_task_id.dart';
|
import 'package:tmail_ui_user/features/upload/domain/model/upload_task_id.dart';
|
||||||
import 'package:tmail_ui_user/features/upload/domain/state/attachment_upload_state.dart';
|
import 'package:tmail_ui_user/features/upload/domain/state/attachment_upload_state.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||||
|
|
||||||
class UploadAttachment with EquatableMixin {
|
class UploadAttachment with EquatableMixin {
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ class UploadAttachment with EquatableMixin {
|
|||||||
final Uri uploadUri;
|
final Uri uploadUri;
|
||||||
final FileUploader fileUploader;
|
final FileUploader fileUploader;
|
||||||
final CancelToken? cancelToken;
|
final CancelToken? cancelToken;
|
||||||
|
final ExceptionThrower exceptionThrower;
|
||||||
|
|
||||||
final StreamController<Either<Failure, Success>> _progressStateController
|
final StreamController<Either<Failure, Success>> _progressStateController
|
||||||
= StreamController<Either<Failure, Success>>.broadcast();
|
= StreamController<Either<Failure, Success>>.broadcast();
|
||||||
@@ -29,6 +31,7 @@ class UploadAttachment with EquatableMixin {
|
|||||||
this.fileInfo,
|
this.fileInfo,
|
||||||
this.uploadUri,
|
this.uploadUri,
|
||||||
this.fileUploader,
|
this.fileUploader,
|
||||||
|
this.exceptionThrower,
|
||||||
{this.cancelToken});
|
{this.cancelToken});
|
||||||
|
|
||||||
void _updateEvent(Either<Failure, Success> flowUploadState) {
|
void _updateEvent(Either<Failure, Success> flowUploadState) {
|
||||||
@@ -57,12 +60,16 @@ class UploadAttachment with EquatableMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_updateEvent(Right(SuccessAttachmentUploadState(uploadTaskId, attachment, fileInfo)));
|
_updateEvent(Right(SuccessAttachmentUploadState(uploadTaskId, attachment, fileInfo)));
|
||||||
} catch (e) {
|
} catch (error, stackTrace) {
|
||||||
logError('UploadAttachment::upload():ERROR: $e');
|
logError('UploadAttachment::upload():ERROR: $error');
|
||||||
if (e is DioError && e.type == DioErrorType.cancel) {
|
if (error is DioError && error.type == DioErrorType.cancel) {
|
||||||
_updateEvent(Left(CancelAttachmentUploadState(uploadTaskId)));
|
_updateEvent(Left(CancelAttachmentUploadState(uploadTaskId)));
|
||||||
} else {
|
} else {
|
||||||
_updateEvent(Left(ErrorAttachmentUploadState(uploadId: uploadTaskId)));
|
try {
|
||||||
|
exceptionThrower.throwException(error, stackTrace);
|
||||||
|
} catch (e) {
|
||||||
|
_updateEvent(Left(ErrorAttachmentUploadState(uploadId: uploadTaskId, exception: e)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await _progressStateController.close();
|
await _progressStateController.close();
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ class UploadController extends BaseController {
|
|||||||
(currentState) => currentState?.copyWith(uploadStatus: UploadFileStatus.uploadFailed));
|
(currentState) => currentState?.copyWith(uploadStatus: UploadFileStatus.uploadFailed));
|
||||||
deleteFileUploaded(failure.uploadId);
|
deleteFileUploaded(failure.uploadId);
|
||||||
_showToastMessageWhenUploadAttachmentsFailure(failure);
|
_showToastMessageWhenUploadAttachmentsFailure(failure);
|
||||||
|
consumeState(Stream.value((Left(failure))));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(success) {
|
(success) {
|
||||||
@@ -143,6 +144,7 @@ class UploadController extends BaseController {
|
|||||||
leadingSVGIconColor: Colors.white,
|
leadingSVGIconColor: Colors.white,
|
||||||
leadingSVGIcon: imagePaths.icInsertImage);
|
leadingSVGIcon: imagePaths.icInsertImage);
|
||||||
}
|
}
|
||||||
|
consumeState(Stream.value((Left(failure))));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(success) {
|
(success) {
|
||||||
|
|||||||
Reference in New Issue
Block a user