TF-2116 Insert image at mouse cursor position
(cherry picked from commit cb347e5077eddb1366daf706aa87eb2291f71aab)
This commit is contained in:
@@ -31,11 +31,24 @@ class SuccessAttachmentUploadState extends Success {
|
||||
final UploadTaskId uploadId;
|
||||
final Attachment attachment;
|
||||
final FileInfo fileInfo;
|
||||
final bool fromFileShared;
|
||||
|
||||
SuccessAttachmentUploadState(this.uploadId, this.attachment, this.fileInfo);
|
||||
SuccessAttachmentUploadState(
|
||||
this.uploadId,
|
||||
this.attachment,
|
||||
this.fileInfo,
|
||||
{
|
||||
this.fromFileShared = false
|
||||
}
|
||||
);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [uploadId, attachment, fileInfo];
|
||||
List<Object?> get props => [
|
||||
uploadId,
|
||||
attachment,
|
||||
fileInfo,
|
||||
fromFileShared,
|
||||
];
|
||||
}
|
||||
|
||||
class ErrorAttachmentUploadState extends Failure {
|
||||
|
||||
@@ -157,8 +157,13 @@ class UploadController extends BaseController {
|
||||
} else if (success is SuccessAttachmentUploadState) {
|
||||
log('UploadController::_handleProgressUploadInlineImageStateStream():succeed[${success.uploadId}]');
|
||||
final inlineAttachment = success.attachment.toAttachmentWithDisposition(
|
||||
disposition: ContentDisposition.inline,
|
||||
cid: _uuid.v1());
|
||||
disposition: ContentDisposition.inline,
|
||||
cid: _uuid.v1()
|
||||
);
|
||||
|
||||
final uploadFileState = _uploadingStateInlineFiles.getUploadFileStateById(success.uploadId);
|
||||
log('UploadController::_handleProgressUploadInlineImageStateStream:uploadId: ${uploadFileState?.uploadTaskId} | fromFileShared: ${uploadFileState?.fromFileShared}');
|
||||
|
||||
_uploadingStateInlineFiles.updateElementByUploadTaskId(
|
||||
success.uploadId,
|
||||
(currentState) {
|
||||
@@ -173,7 +178,9 @@ class UploadController extends BaseController {
|
||||
final newUploadSuccess = SuccessAttachmentUploadState(
|
||||
success.uploadId,
|
||||
inlineAttachment,
|
||||
success.fileInfo);
|
||||
success.fileInfo,
|
||||
fromFileShared: uploadFileState?.fromFileShared ?? false
|
||||
);
|
||||
_handleUploadInlineAttachmentsSuccess(newUploadSuccess);
|
||||
}
|
||||
}
|
||||
@@ -202,13 +209,21 @@ class UploadController extends BaseController {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> uploadFileAction(FileInfo uploadFile, Uri uploadUri, {bool isInline = false}) {
|
||||
log('UploadController::_uploadFile():fileName: ${uploadFile.fileName}');
|
||||
Future<void> uploadFileAction(
|
||||
FileInfo uploadFile,
|
||||
Uri uploadUri,
|
||||
{
|
||||
bool isInline = false,
|
||||
bool fromFileShared = false,
|
||||
}
|
||||
) {
|
||||
log('UploadController::_uploadFile():fileName: ${uploadFile.fileName} | isInline: $isInline | fromFileShared: $fromFileShared');
|
||||
consumeState(_uploadAttachmentInteractor.execute(
|
||||
uploadFile,
|
||||
uploadUri,
|
||||
cancelToken: CancelToken(),
|
||||
isInline: isInline
|
||||
isInline: isInline,
|
||||
fromFileShared: fromFileShared
|
||||
));
|
||||
return Future.value();
|
||||
}
|
||||
@@ -368,7 +383,7 @@ class UploadController extends BaseController {
|
||||
super.handleSuccessViewState(success);
|
||||
if (success is UploadAttachmentSuccess) {
|
||||
if (success.isInline) {
|
||||
_uploadingStateInlineFiles.add(success.uploadAttachment.toUploadFileState());
|
||||
_uploadingStateInlineFiles.add(success.uploadAttachment.toUploadFileState(fromFileShared: success.fromFileShared));
|
||||
await _progressUploadInlineImageStateStreamGroup.add(success.uploadAttachment.progressState);
|
||||
} else {
|
||||
_uploadingStateFiles.add(success.uploadAttachment.toUploadFileState());
|
||||
|
||||
@@ -4,11 +4,12 @@ import 'package:tmail_ui_user/features/upload/presentation/model/upload_file_sta
|
||||
|
||||
extension UploadAttachmentExtension on UploadAttachment {
|
||||
|
||||
UploadFileState toUploadFileState() {
|
||||
UploadFileState toUploadFileState({bool fromFileShared = false}) {
|
||||
return UploadFileState(
|
||||
uploadTaskId,
|
||||
file: fileInfo,
|
||||
cancelToken: cancelToken
|
||||
cancelToken: cancelToken,
|
||||
fromFileShared: fromFileShared,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,19 @@ class UploadFileState with EquatableMixin {
|
||||
final int uploadingProgress;
|
||||
final Attachment? attachment;
|
||||
final CancelToken? cancelToken;
|
||||
final bool fromFileShared;
|
||||
|
||||
UploadFileState(this.uploadTaskId, {
|
||||
this.file,
|
||||
this.uploadStatus = UploadFileStatus.waiting,
|
||||
this.uploadingProgress = 0,
|
||||
this.attachment,
|
||||
this.cancelToken,
|
||||
});
|
||||
UploadFileState(
|
||||
this.uploadTaskId,
|
||||
{
|
||||
this.file,
|
||||
this.uploadStatus = UploadFileStatus.waiting,
|
||||
this.uploadingProgress = 0,
|
||||
this.attachment,
|
||||
this.cancelToken,
|
||||
this.fromFileShared = false,
|
||||
}
|
||||
);
|
||||
|
||||
UploadFileState copyWith({
|
||||
UploadTaskId? uploadTaskId,
|
||||
@@ -33,7 +38,8 @@ class UploadFileState with EquatableMixin {
|
||||
UploadFileStatus? uploadStatus,
|
||||
int? uploadingProgress,
|
||||
Attachment? attachment,
|
||||
CancelToken? cancelToken
|
||||
CancelToken? cancelToken,
|
||||
bool? fromFileShared,
|
||||
}) {
|
||||
return UploadFileState(
|
||||
uploadTaskId ?? this.uploadTaskId,
|
||||
@@ -41,7 +47,8 @@ class UploadFileState with EquatableMixin {
|
||||
uploadStatus: uploadStatus ?? this.uploadStatus,
|
||||
uploadingProgress: uploadingProgress ?? this.uploadingProgress,
|
||||
attachment: attachment ?? this.attachment,
|
||||
cancelToken: cancelToken ?? this.cancelToken
|
||||
cancelToken: cancelToken ?? this.cancelToken,
|
||||
fromFileShared: fromFileShared ?? this.fromFileShared
|
||||
);
|
||||
}
|
||||
|
||||
@@ -96,6 +103,8 @@ class UploadFileState with EquatableMixin {
|
||||
file,
|
||||
uploadStatus,
|
||||
uploadingProgress,
|
||||
attachment
|
||||
attachment,
|
||||
cancelToken,
|
||||
fromFileShared,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -66,4 +66,8 @@ class UploadFileStateList {
|
||||
_uploadingStateFiles.remove(fileState);
|
||||
}
|
||||
}
|
||||
|
||||
UploadFileState? getUploadFileStateById(UploadTaskId uploadTaskId) {
|
||||
return _uploadingStateFiles.firstWhereOrNull((fileState) => fileState?.uploadTaskId == uploadTaskId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user