@@ -86,8 +86,6 @@ import 'package:tmail_ui_user/features/email/domain/usecases/transform_html_emai
8686import 'package:tmail_ui_user/features/email/presentation/extensions/presentation_email_extension.dart' ;
8787import 'package:tmail_ui_user/features/email/presentation/model/composer_arguments.dart' ;
8888import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart' ;
89- import 'package:tmail_ui_user/features/mailbox_dashboard/domain/usecases/remove_composer_cache_by_id_on_web_interactor.dart' ;
90- import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart' ;
9189import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart' ;
9290import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/open_and_close_composer_extension.dart' ;
9391import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/remove_local_email_draft_extension.dart' ;
@@ -223,17 +221,14 @@ class ComposerController extends BaseController
223221 ButtonState _saveToDraftButtonState = ButtonState .enabled;
224222 ButtonState _sendButtonState = ButtonState .enabled;
225223 ButtonState printDraftButtonState = ButtonState .enabled;
226- int ? _savedEmailDraftHash ;
224+ int ? savedEmailDraftHash ;
227225 bool restoringSignatureButton = false ;
228226 bool synchronizeInitDraftHash = false ;
229227 GlobalKey ? responsiveContainerKey;
230228 EmailActionType ? currentEmailActionType;
231229 EmailActionType ? savedActionType;
232230 int minInputLengthAutocomplete = AppConfig .defaultMinInputLengthAutocomplete;
233231
234- @visibleForTesting
235- int ? get savedEmailDraftHash => _savedEmailDraftHash;
236-
237232 GetEmailContentInteractor get getEmailContentInteractor => _getEmailContentInteractor;
238233
239234 GetServerSettingInteractor get getServerSettingInteractor => _getServerSettingInteractor;
@@ -300,7 +295,7 @@ class ComposerController extends BaseController
300295 void onClose () {
301296 _textEditorWeb = null ;
302297 savedActionType = null ;
303- _savedEmailDraftHash = null ;
298+ savedEmailDraftHash = null ;
304299 currentEmailActionType = null ;
305300 emailIdEditing = null ;
306301 maxWithEditor = null ;
@@ -447,19 +442,7 @@ class ComposerController extends BaseController
447442 });
448443 }
449444
450- Future <void > _saveLocalEmailDraftAction () async {
451- autoCreateEmailTag ();
452-
453- final createEmailRequest = await _generateCreateEmailRequestToSaveAsCache ();
454- if (createEmailRequest == null ) return ;
455-
456- await _saveLocalEmailDraftInteractor.execute (
457- createEmailRequest,
458- mailboxDashBoardController.accountId.value! ,
459- mailboxDashBoardController.sessionCurrent! .username);
460- }
461-
462- Uri ? _getUploadUriFromSession (Session session, AccountId accountId) {
445+ Uri ? getUploadUriFromSession (Session session, AccountId accountId) {
463446 try {
464447 return session.getUploadUri (accountId, jmapUrl: dynamicUrlInterceptors.jmapUrl);
465448 } catch (e) {
@@ -468,63 +451,6 @@ class ComposerController extends BaseController
468451 }
469452 }
470453
471- Future <CreateEmailRequest ?> _generateCreateEmailRequestToSaveAsCache () async {
472- final arguments = composerArguments.value;
473- final session = mailboxDashBoardController.sessionCurrent;
474- final accountId = mailboxDashBoardController.accountId.value;
475-
476- if (arguments == null || session == null || accountId == null ) {
477- log ('ComposerController::_generateCreateEmailRequest: SESSION or ACCOUNT_ID or ARGUMENTS is NULL' );
478- return null ;
479- }
480-
481- String emailContent = await getContentInEditor ();
482- if (currentEmailActionType == EmailActionType .compose) {
483- emailContent = await _composerRepository.removeCollapsedExpandedSignatureEffect (
484- emailContent: emailContent,
485- );
486- }
487- final uploadUri = _getUploadUriFromSession (session, accountId);
488-
489- final composerIndex = composerId != null
490- ? mailboxDashBoardController.composerManager.getComposerIndex (composerId! )
491- : null ;
492-
493- return CreateEmailRequest (
494- session: session,
495- accountId: accountId,
496- emailActionType: arguments.emailActionType,
497- subject: subjectEmail.value ?? '' ,
498- emailContent: emailContent,
499- fromSender: arguments.presentationEmail? .from ?? {},
500- toRecipients: listToEmailAddress.toSet (),
501- ccRecipients: listCcEmailAddress.toSet (),
502- bccRecipients: listBccEmailAddress.toSet (),
503- replyToRecipients: listReplyToEmailAddress.toSet (),
504- hasRequestReadReceipt: hasRequestReadReceipt.value,
505- isMarkAsImportant: isMarkAsImportant.value,
506- identity: identitySelected.value,
507- attachments: uploadController.attachmentsUploaded,
508- inlineAttachments: uploadController.mapInlineAttachments,
509- outboxMailboxId: getOutboxMailboxIdForComposer (),
510- sentMailboxId: getSentMailboxIdForComposer (),
511- draftsMailboxId: getDraftMailboxIdForComposer (),
512- draftsEmailId: getDraftEmailId (),
513- answerForwardEmailId: arguments.presentationEmail? .id,
514- unsubscribeEmailId: arguments.previousEmailId,
515- messageId: arguments.messageId,
516- references: arguments.references,
517- emailSendingQueue: arguments.sendingEmail,
518- displayMode: screenDisplayMode.value,
519- uploadUri: uploadUri,
520- composerIndex: composerIndex,
521- composerId: composerId,
522- savedDraftHash: arguments.savedDraftHash ?? _savedEmailDraftHash,
523- savedActionType: savedActionType ?? currentEmailActionType,
524- savedEmailDraftId: emailIdEditing,
525- );
526- }
527-
528454 void _scrollControllerEmailAddressListener () {
529455 if (toEmailAddressController.text.isNotEmpty) {
530456 keyToEmailTagEditor.currentState? .closeSuggestionBox ();
@@ -1101,8 +1027,8 @@ class ComposerController extends BaseController
11011027
11021028 Future <bool > _validateEmailChange () async {
11031029 final newDraftHash = await _hashDraftEmail ();
1104- log ('ComposerController::_validateEmailChange:newDraftHash = $newDraftHash | _savedEmailDraftHash = $_savedEmailDraftHash ' );
1105- return _savedEmailDraftHash != newDraftHash;
1030+ log ('ComposerController::_validateEmailChange:newDraftHash = $newDraftHash | savedEmailDraftHash = $savedEmailDraftHash ' );
1031+ return savedEmailDraftHash != newDraftHash;
11061032 }
11071033
11081034 Future <int > _hashDraftEmail () async {
@@ -1113,7 +1039,7 @@ class ComposerController extends BaseController
11131039 );
11141040 if (emailIdEditing != null &&
11151041 savedActionType == EmailActionType .compose &&
1116- currentEmailActionType == EmailActionType .reopenComposerBrowser ) {
1042+ currentEmailActionType == EmailActionType .composeFromLocalEmailDraft ) {
11171043 emailContent = await _composerRepository.removeStyleLazyLoadDisplayInlineImages (
11181044 emailContent: emailContent,
11191045 );
@@ -1138,7 +1064,7 @@ class ComposerController extends BaseController
11381064 }
11391065
11401066 Future <void > _updateSavedEmailDraftHash () async {
1141- _savedEmailDraftHash = await _hashDraftEmail ();
1067+ savedEmailDraftHash = await _hashDraftEmail ();
11421068 }
11431069
11441070 Future <void > initEmailDraftHash () async {
@@ -1148,13 +1074,13 @@ class ComposerController extends BaseController
11481074
11491075 if (currentEmailActionType == EmailActionType .compose ||
11501076 currentEmailActionType == EmailActionType .editDraft) {
1151- _savedEmailDraftHash = currentDraftHash;
1152- } else if (currentEmailActionType == EmailActionType .reopenComposerBrowser ) {
1153- _savedEmailDraftHash = oldSavedDraftHash;
1077+ savedEmailDraftHash = currentDraftHash;
1078+ } else if (currentEmailActionType == EmailActionType .composeFromLocalEmailDraft ) {
1079+ savedEmailDraftHash = oldSavedDraftHash;
11541080 }
1155- log ('ComposerController::initEmailDraftHash:oldSavedDraftHash = $oldSavedDraftHash | currentDraftHash = $currentDraftHash | _savedEmailDraftHash = $_savedEmailDraftHash ' );
1081+ log ('ComposerController::initEmailDraftHash:oldSavedDraftHash = $oldSavedDraftHash | currentDraftHash = $currentDraftHash | savedEmailDraftHash = $savedEmailDraftHash ' );
11561082
1157- isEmailChanged.value = currentDraftHash != _savedEmailDraftHash ;
1083+ isEmailChanged.value = currentDraftHash != savedEmailDraftHash ;
11581084 }
11591085
11601086 void handleClickSaveAsDraftsButton (BuildContext context) async {
0 commit comments