Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-2532 Add attachment/inlineImage to app bar composer Mobile/Tablet #2546

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,18 @@ class DownloadImageAsBase64Success extends UIState {
final String base64Uri;
final String cid;
final FileInfo fileInfo;
final bool fromFileShared;

DownloadImageAsBase64Success(
this.base64Uri,
this.cid,
this.fileInfo,
{
this.fromFileShared = false
}
);

@override
List<Object?> get props => [
base64Uri,
cid,
fileInfo,
fromFileShared,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class DownloadImageAsBase64Interactor {
{
double? maxWidth,
bool? compress,
bool fromFileShared = false,
}
) async* {
try {
Expand All @@ -33,7 +32,6 @@ class DownloadImageAsBase64Interactor {
result!,
cid,
fileInfo,
fromFileShared: fromFileShared
));
} else {
yield Left<Failure, Success>(DownloadImageAsBase64Failure(null));
Expand Down
2 changes: 0 additions & 2 deletions lib/features/composer/presentation/composer_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ class ComposerController extends BaseController {
cid: success.cid,
base64Uri: success.base64Uri
),
fromFileShare: success.fromFileShared
);
}
maxWithEditor = null;
Expand Down Expand Up @@ -1863,7 +1862,6 @@ class ComposerController extends BaseController {
uploadState.attachment.cid!,
uploadState.fileInfo,
maxWidth: maxWithEditor,
fromFileShared: uploadState.fromFileShared,
));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,16 @@ import 'package:tmail_ui_user/features/composer/presentation/model/inline_image.
class RichTextMobileTabletController extends BaseRichTextController {
HtmlEditorApi? htmlEditorApi;

void insertImage(
InlineImage image,
{
double? maxWithEditor,
bool fromFileShare = false
}
) async {
log('RichTextMobileTabletController::insertImage(): $image | maxWithEditor: $maxWithEditor | $fromFileShare');
if (image.source == ImageSource.network) {
htmlEditorApi?.insertImageLink(image.link!);
void insertImage(InlineImage inlineImage) async {
if (inlineImage.source == ImageSource.network) {
htmlEditorApi?.insertImageLink(inlineImage.link!);
} else {
if (fromFileShare) {
await htmlEditorApi?.moveCursorAtLastNode();
bool isEditorFocused = await htmlEditorApi?.hasFocus() ?? false;
log('RichTextMobileTabletController::insertImage: isEditorFocused = $isEditorFocused');
if (!isEditorFocused) {
await htmlEditorApi?.requestFocusLastChild();
}
await htmlEditorApi?.insertHtml(image.base64Uri ?? '');
await htmlEditorApi?.insertHtml('${inlineImage.base64Uri ?? ''}<br/><br/>');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,18 @@ class SuccessAttachmentUploadState extends Success {
final UploadTaskId uploadId;
final Attachment attachment;
final FileInfo fileInfo;
final bool fromFileShared;

SuccessAttachmentUploadState(
this.uploadId,
this.attachment,
this.fileInfo,
{
this.fromFileShared = false
}
this.fileInfo
);

@override
List<Object?> get props => [
uploadId,
attachment,
fileInfo,
fromFileShared,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ class UploadController extends BaseController {
cid: uuid.v1()
);

final uploadFileState = _uploadingStateInlineFiles.getUploadFileStateById(success.uploadId);
log('UploadController::_handleProgressUploadInlineImageStateStream:uploadId: ${uploadFileState?.uploadTaskId} | fromFileShared: ${uploadFileState?.fromFileShared}');

_uploadingStateInlineFiles.updateElementByUploadTaskId(
success.uploadId,
(currentState) {
Expand All @@ -173,7 +170,6 @@ class UploadController extends BaseController {
success.uploadId,
inlineAttachment,
success.fileInfo,
fromFileShared: uploadFileState?.fromFileShared ?? false
);
_handleUploadInlineAttachmentsSuccess(newUploadSuccess);
}
Expand Down Expand Up @@ -378,7 +374,7 @@ class UploadController extends BaseController {
super.handleSuccessViewState(success);
if (success is UploadAttachmentSuccess) {
if (success.isInline) {
_uploadingStateInlineFiles.add(success.uploadAttachment.toUploadFileState(fromFileShared: success.fromFileShared));
_uploadingStateInlineFiles.add(success.uploadAttachment.toUploadFileState());
await _progressUploadInlineImageStateStreamGroup.add(success.uploadAttachment.progressState);
} else {
_uploadingStateFiles.add(success.uploadAttachment.toUploadFileState());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import 'package:tmail_ui_user/features/upload/presentation/model/upload_file_sta

extension UploadAttachmentExtension on UploadAttachment {

UploadFileState toUploadFileState({bool fromFileShared = false}) {
UploadFileState toUploadFileState() {
return UploadFileState(
uploadTaskId,
file: fileInfo,
cancelToken: cancelToken,
fromFileShared: fromFileShared,
);
}
}
5 changes: 0 additions & 5 deletions lib/features/upload/presentation/model/upload_file_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class UploadFileState with EquatableMixin {
final int uploadingProgress;
final Attachment? attachment;
final CancelToken? cancelToken;
final bool fromFileShared;

UploadFileState(
this.uploadTaskId,
Expand All @@ -28,7 +27,6 @@ class UploadFileState with EquatableMixin {
this.uploadingProgress = 0,
this.attachment,
this.cancelToken,
this.fromFileShared = false,
}
);

Expand All @@ -39,7 +37,6 @@ class UploadFileState with EquatableMixin {
int? uploadingProgress,
Attachment? attachment,
CancelToken? cancelToken,
bool? fromFileShared,
}) {
return UploadFileState(
uploadTaskId ?? this.uploadTaskId,
Expand All @@ -48,7 +45,6 @@ class UploadFileState with EquatableMixin {
uploadingProgress: uploadingProgress ?? this.uploadingProgress,
attachment: attachment ?? this.attachment,
cancelToken: cancelToken ?? this.cancelToken,
fromFileShared: fromFileShared ?? this.fromFileShared
hoangdat marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down Expand Up @@ -105,6 +101,5 @@ class UploadFileState with EquatableMixin {
uploadingProgress,
attachment,
cancelToken,
fromFileShared,
];
}
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ packages:
dependency: transitive
description:
path: "."
ref: "bugfix/build-failed-on-android"
resolved-ref: "33991d46432a22a79b5d3593262033ae49da77f6"
ref: email_supported
resolved-ref: "562ef89121d2ea8b12340cdf0998104b3fc25857"
url: "https://github.com/linagora/enough_html_editor.git"
source: git
version: "0.0.5"
Expand Down Expand Up @@ -1540,7 +1540,7 @@ packages:
description:
path: "."
ref: master
resolved-ref: "9c0eb7e3627af6ba6860e986ec6ac1f6f170c71d"
resolved-ref: "91809cfa3095b71f3cce04e8f29f38c238d2e770"
url: "https://github.com/linagora/rich-text-composer.git"
source: git
version: "0.0.2"
Expand Down