TF-3480 Fix reload multiple times, if composer is in minimize or hide, content maybe lost
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -74,6 +74,7 @@ import 'package:tmail_ui_user/features/composer/presentation/model/inline_image.
|
|||||||
import 'package:tmail_ui_user/features/composer/presentation/model/prefix_recipient_state.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/model/prefix_recipient_state.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/model/screen_display_mode.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/styles/composer_style.dart';
|
||||||
|
import 'package:tmail_ui_user/features/composer/presentation/view/editor_view_mixin.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/mobile/from_composer_bottom_sheet_builder.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/mobile/from_composer_bottom_sheet_builder.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/saving_message_dialog_view.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/saving_message_dialog_view.dart';
|
||||||
import 'package:tmail_ui_user/features/composer/presentation/widgets/sending_message_dialog_view.dart';
|
import 'package:tmail_ui_user/features/composer/presentation/widgets/sending_message_dialog_view.dart';
|
||||||
@@ -116,7 +117,7 @@ import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
|||||||
import 'package:tmail_ui_user/main/universal_import/html_stub.dart' as html;
|
import 'package:tmail_ui_user/main/universal_import/html_stub.dart' as html;
|
||||||
|
|
||||||
class ComposerController extends BaseController
|
class ComposerController extends BaseController
|
||||||
with DragDropFileMixin, AutoCompleteResultMixin
|
with DragDropFileMixin, AutoCompleteResultMixin, EditorViewMixin
|
||||||
implements BeforeReconnectHandler {
|
implements BeforeReconnectHandler {
|
||||||
|
|
||||||
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
|
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
|
||||||
@@ -213,7 +214,6 @@ class ComposerController extends BaseController
|
|||||||
|
|
||||||
List<Attachment> initialAttachments = <Attachment>[];
|
List<Attachment> initialAttachments = <Attachment>[];
|
||||||
String? _textEditorWeb;
|
String? _textEditorWeb;
|
||||||
String? _initTextEditor;
|
|
||||||
double? maxWithEditor;
|
double? maxWithEditor;
|
||||||
EmailId? _emailIdEditing;
|
EmailId? _emailIdEditing;
|
||||||
bool isAttachmentCollapsed = false;
|
bool isAttachmentCollapsed = false;
|
||||||
@@ -225,6 +225,7 @@ class ComposerController extends BaseController
|
|||||||
int? _savedEmailDraftHash;
|
int? _savedEmailDraftHash;
|
||||||
bool _restoringSignatureButton = false;
|
bool _restoringSignatureButton = false;
|
||||||
GlobalKey? responsiveContainerKey;
|
GlobalKey? responsiveContainerKey;
|
||||||
|
Worker? emailContentViewStateWorker;
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
bool get restoringSignatureButton => _restoringSignatureButton;
|
bool get restoringSignatureButton => _restoringSignatureButton;
|
||||||
@@ -286,7 +287,6 @@ class ComposerController extends BaseController
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void onClose() {
|
void onClose() {
|
||||||
_initTextEditor = null;
|
|
||||||
_textEditorWeb = null;
|
_textEditorWeb = null;
|
||||||
dispatchState(Right(UIClosedState()));
|
dispatchState(Right(UIClosedState()));
|
||||||
composerArguments.value = null;
|
composerArguments.value = null;
|
||||||
@@ -305,6 +305,8 @@ class ComposerController extends BaseController
|
|||||||
responsiveContainerKey = null;
|
responsiveContainerKey = null;
|
||||||
menuMoreOptionController?.dispose();
|
menuMoreOptionController?.dispose();
|
||||||
menuMoreOptionController = null;
|
menuMoreOptionController = null;
|
||||||
|
emailContentViewStateWorker?.dispose();
|
||||||
|
emailContentViewStateWorker = null;
|
||||||
} else {
|
} else {
|
||||||
richTextMobileTabletController = null;
|
richTextMobileTabletController = null;
|
||||||
}
|
}
|
||||||
@@ -441,6 +443,39 @@ class ComposerController extends BaseController
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (PlatformInfo.isWeb) {
|
||||||
|
emailContentViewStateWorker = ever(emailContentsViewState, (state) {
|
||||||
|
state?.fold((_) => null, (success) {
|
||||||
|
if (success is GetEmailContentSuccess) {
|
||||||
|
onChangeTextEditorWeb(success.htmlEmailContent);
|
||||||
|
} else if (success is TransformHtmlEmailContentSuccess) {
|
||||||
|
final arguments = composerArguments.value;
|
||||||
|
if (arguments == null ||
|
||||||
|
currentContext == null ||
|
||||||
|
arguments.presentationEmail == null) return;
|
||||||
|
|
||||||
|
final emailActionType = arguments.emailActionType;
|
||||||
|
|
||||||
|
if (emailActionType == EmailActionType.reply ||
|
||||||
|
emailActionType == EmailActionType.replyAll ||
|
||||||
|
emailActionType == EmailActionType.replyToList ||
|
||||||
|
emailActionType == EmailActionType.forward) {
|
||||||
|
|
||||||
|
final emailContentQuoted = getEmailContentQuotedAsHtml(
|
||||||
|
locale: Localizations.localeOf(currentContext!),
|
||||||
|
appLocalizations: AppLocalizations.of(currentContext!),
|
||||||
|
emailContent: success.htmlContent,
|
||||||
|
emailActionType: arguments.emailActionType,
|
||||||
|
presentationEmail: arguments.presentationEmail!
|
||||||
|
);
|
||||||
|
|
||||||
|
onChangeTextEditorWeb(emailContentQuoted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _triggerBrowserEventListener() {
|
void _triggerBrowserEventListener() {
|
||||||
@@ -601,9 +636,6 @@ class ComposerController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onCreatedMobileEditorAction(BuildContext context, HtmlEditorApi editorApi, String? content) {
|
void onCreatedMobileEditorAction(BuildContext context, HtmlEditorApi editorApi, String? content) {
|
||||||
if (identitySelected.value != null) {
|
|
||||||
initTextEditor(content);
|
|
||||||
}
|
|
||||||
richTextMobileTabletController?.htmlEditorApi = editorApi;
|
richTextMobileTabletController?.htmlEditorApi = editorApi;
|
||||||
richTextMobileTabletController?.richTextController.onCreateHTMLEditor(
|
richTextMobileTabletController?.richTextController.onCreateHTMLEditor(
|
||||||
editorApi,
|
editorApi,
|
||||||
@@ -2105,11 +2137,7 @@ class ComposerController extends BaseController
|
|||||||
HtmlEditorApi? get htmlEditorApi => richTextMobileTabletController?.htmlEditorApi;
|
HtmlEditorApi? get htmlEditorApi => richTextMobileTabletController?.htmlEditorApi;
|
||||||
|
|
||||||
void onChangeTextEditorWeb(String? text) {
|
void onChangeTextEditorWeb(String? text) {
|
||||||
if (identitySelected.value != null) {
|
|
||||||
initTextEditor(text);
|
|
||||||
}
|
|
||||||
_textEditorWeb = text;
|
_textEditorWeb = text;
|
||||||
|
|
||||||
_initEmailDraftHashAfterSignatureButtonRestored(text);
|
_initEmailDraftHashAfterSignatureButtonRestored(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2123,14 +2151,8 @@ class ComposerController extends BaseController
|
|||||||
_initEmailDraftHash();
|
_initEmailDraftHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTextEditor(String? text) {
|
|
||||||
_initTextEditor ??= text;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSubjectEmail(String subject) => subjectEmail.value = subject;
|
void setSubjectEmail(String subject) => subjectEmail.value = subject;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void onAttachmentDropZoneListener(Attachment attachment) {
|
void onAttachmentDropZoneListener(Attachment attachment) {
|
||||||
log('ComposerController::onAttachmentDropZoneListener: attachment = $attachment');
|
log('ComposerController::onAttachmentDropZoneListener: attachment = $attachment');
|
||||||
uploadController.validateTotalSizeAttachmentsBeforeUpload(
|
uploadController.validateTotalSizeAttachmentsBeforeUpload(
|
||||||
|
|||||||
Reference in New Issue
Block a user