TF-3643 Thread Detail get emails meta data method

TF-3643 Thread Detail cache email with thread id

TF-3643 Thread Detail view thread detail

TF-3643 Thread Detail [Part 2 fixup] remove ThreadDetailController dependency from MailboxDashboardController

TF-3643 Thread Detail [Part 2 fixup] remove EmailSupervisorController dependency from ThreadDetailController

TF-3643 Thread Detail [Part 2 fixup] move isSearchRunning check into ThreadDetailController

TF-3643 Thread Detail [Part 2 fixup] ensure GetEmailsByIdsInteractor performance

TF-3643 Thread Detail [Part 2 fixup] unit test loadMoreThreadDetailEmails

TF-3643 Thread Detail [Part 2 fixup] unit test getEmailIdsToLoad

TF-3643 Thread Detail [Part 2 fixup] optimize ThreadDetailBinding bindingsDataSource

TF-3643 Thread Detail [Part 2 fixup] optimize getThreadDetailLoadingView

TF-3643 Thread Detail [Part 2 fixup] readd unique ValueKey for HtmlContentViewerOnWebWidget

TF-3643 Thread Detail [Part 2 fixup] unit test initializeThreadDetailEmails

TF-3643 Thread Detail [Part 3 fixup] Update private action button methods

TF-3643 Thread Detail [Part 4 fixup] Collapsed email preview 65 characters max

TF-3643 Thread Detail [Part 4 fixup] Remove personal scripts

TF-3643 Thread Detail move EmailInThreadStatus into PresentationEmail

TF-3643 Thread Detail refactor toggle collapse expand

TF-3643 Thread Detail EmailViewAppBarWidget required parameters

TF-3643 Thread Detail tap avatar toggle expansion

TF-3643 Thread Detail fix cannot open single email

TF-3643 Thread Detail fix open thread first time blank view

TF-3643 Thread Detail fix thread detail UI

TF-3643 Thread Detail fix round bottom view

TF-3643 Thread Detail fix round bottom view

TF-3643 Thread Detail bottom actions depend on current expanded email

TF-3643 Thread Detail hide next previous actions

TF-3643 Thread Detail fix load more show initial loading view

TF-3643 Thread Detail fix cannot view single email

TF-3643 Thread Detail fix bottom place holder not aligned

TF-3643 Thread Detail fix back to search view

TF-3643 Thread Detail fix display 65 character preview collapsed email

TF-3643 Thread Detail fix search not work

TF-3643 Thread Detail fix bottom place holder UI

TF-3643 Thread Detail fix expand view

TF-3643 Thread Detail jump to top of last email view

TF-3643 Thread Detail remove toMe condition of filtering thread

TF-3643 Thread Detail fix sort thread detail

TF-3643 Thread Detail fix assert not work in release

TF-3643 Thread Detail add load more test case <20

TF-3643 Thread Detail remove the use of currentThreadId

TF-3643 Thread Detail remove the use of selectedEmail in SingleEmailController

TF-3643 Thread Detail fix unit test SingleEmailController calendar

TF-3643 Thread Detail disable 2 way scroll control

TF-3643 Thread Detail allow thread to load sent email incase thread only contains 1 email

TF-3643 Thread Detail disable single email page view

TF-3643 Thread Detail update emailsNotLoadedCount name

TF-3643 Thread Detail remove collapsed email char limit

TF-3643 Thread Detail fix CI

TF-3643 Thread Detail unit test handleGetEmailIdsByThreadIdSuccess

TF-3643 Thread Detail make _currentEmailId private

TF-3643 Thread Detail fix search click users

TF-3643 Thread Detail fix scroll jump

TF-3643 Thread Detail fix scroll jump

TF-3643 Thread Detail fix web back action

TF-3643 Thread Detail round bottom actions

TF-3643 Thread Detail fix tablet large empty email

TF-3643 Thread Detail fix email subject selectable

TF-3643 Thread Detail fix email single view with top divider

TF-3643 Thread Detail fix email cache threadId missing

TF-3643 Thread Detail fix filter sent email in thread details

TF-3643 Thread Detail fix select text

TF-3643 Thread Detail fix subject alignment

TF-3643 Thread Detail fix subject alignment

TF-3643 Thread Detail fix tablet large empty email

TF-3643 Thread Detail add nullcheck for _jumpScrollViewToTopOfEmail

TF-3643 Thread Detail decouple ThreadDetailController from SingleEmailController

TF-3643 Thread Detail combine emailIds to emailIdsPresentation

TF-3643 Thread Detail remove currentEmailLoaded obx listener of SingleEmailController

TF-3643 Thread Detail replace threadAction with an email ui action

TF-3643 Thread Detail fix top and bottom bar delay displaying

TF-3643 Thread Detail update ReplyForwardBottomBarAction to PerformEmailActionInThreadDetailAction

TF-3643 Thread Detail use getOwnEmailAddress in ThreadDetailAppBar

TF-3643 Thread Detail add TextOverflow.ellipsis to EmailSubjectWidget

TF-3643 Thread Detail fix round border threadDetailLoadingView
This commit is contained in:
DatDang
2025-05-12 15:22:29 +07:00
committed by Dat H. Pham
parent 7c3af832e4
commit 58a576adeb
84 changed files with 2845 additions and 558 deletions
@@ -101,7 +101,6 @@ import 'package:tmail_ui_user/features/email/domain/usecases/send_receipt_to_sen
import 'package:tmail_ui_user/features/email/domain/usecases/store_opened_email_interactor.dart';
import 'package:tmail_ui_user/features/email/presentation/action/email_ui_action.dart';
import 'package:tmail_ui_user/features/email/presentation/bindings/calendar_event_interactor_bindings.dart';
import 'package:tmail_ui_user/features/email/presentation/controller/email_supervisor_controller.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/attachment_extension.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_attendee_extension.dart';
import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_organizer_extension.dart';
@@ -135,8 +134,10 @@ import 'package:tmail_ui_user/features/manage_account/domain/usecases/create_new
import 'package:tmail_ui_user/features/manage_account/domain/usecases/get_all_identities_interactor.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/extensions/datetime_extension.dart';
import 'package:tmail_ui_user/features/rules_filter_creator/presentation/model/rules_filter_creator_arguments.dart';
import 'package:tmail_ui_user/features/thread/domain/constants/thread_constants.dart';
import 'package:tmail_ui_user/features/search/email/presentation/search_email_controller.dart';
import 'package:tmail_ui_user/features/thread/presentation/model/delete_action_type.dart';
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/focus_thread_detail_expanded_email.dart';
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
import 'package:tmail_ui_user/main/error/capability_validator.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
import 'package:tmail_ui_user/main/localizations/localization_service.dart';
@@ -156,7 +157,6 @@ import 'package:twake_previewer_flutter/twake_plain_text_previewer/twake_plain_t
class SingleEmailController extends BaseController with AppLoaderMixin {
final mailboxDashBoardController = Get.find<MailboxDashBoardController>();
final emailSupervisorController = Get.find<EmailSupervisorController>();
final _downloadManager = Get.find<DownloadManager>();
final _printUtils = Get.find<PrintUtils>();
final _attachmentListScrollController = ScrollController();
@@ -177,6 +177,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final GetHtmlContentFromAttachmentInteractor _getHtmlContentFromAttachmentInteractor;
final DownloadAllAttachmentsForWebInteractor _downloadAllAttachmentsForWebInteractor;
final ExportAllAttachmentsInteractor _exportAllAttachmentsInteractor;
final EmailId? _currentEmailId;
CreateNewEmailRuleFilterInteractor? _createNewEmailRuleFilterInteractor;
SendReceiptToSenderInteractor? _sendReceiptToSenderInteractor;
@@ -185,6 +186,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
MaybeCalendarEventInteractor? _maybeCalendarEventInteractor;
RejectCalendarEventInteractor? _rejectCalendarEventInteractor;
AcceptCounterCalendarEventInteractor? _acceptCounterCalendarEventInteractor;
ThreadDetailController? _threadDetailController;
final emailContents = RxnString();
final attachments = <Attachment>[].obs;
@@ -198,15 +200,19 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final attendanceStatus = Rxn<AttendanceStatus>();
final htmlContentViewKey = GlobalKey<HtmlContentViewState>();
EmailId? _currentEmailId;
Identity? _identitySelected;
ButtonState? _printEmailButtonState;
final obxListeners = <Worker>[];
final StreamController<Either<Failure, Success>> _downloadProgressStateController =
StreamController<Either<Failure, Success>>.broadcast();
Stream<Either<Failure, Success>> get downloadProgressState => _downloadProgressStateController.stream;
PresentationEmail? get currentEmail => mailboxDashBoardController.selectedEmail.value;
PresentationEmail? get currentEmail {
return _currentEmailId == null
? null
: _threadDetailController?.emailIdsPresentation[_currentEmailId];
}
bool get calendarEventProcessing => viewState.value.fold(
(failure) => false,
@@ -238,11 +244,14 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
this._previewEmailFromEmlFileInteractor,
this._getHtmlContentFromAttachmentInteractor,
this._downloadAllAttachmentsForWebInteractor,
this._exportAllAttachmentsInteractor,
);
this._exportAllAttachmentsInteractor, {
EmailId? currentEmailId,
}) : _currentEmailId = currentEmailId;
@override
void onInit() {
_threadDetailController = getBinding<ThreadDetailController>();
_injectCalendarEventBindings(session, accountId);
_registerObxStreamListener();
_listenDownloadAttachmentProgressState();
super.onInit();
@@ -250,6 +259,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
@override
void onClose() {
_threadDetailController = null;
_downloadProgressStateController.close();
_attachmentListScrollController.dispose();
super.onClose();
@@ -357,28 +367,15 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _registerObxStreamListener() {
ever(mailboxDashBoardController.accountId, (accountId) {
if (accountId is AccountId) {
_injectAndGetInteractorBindings(
session,
accountId
);
}
if (accountId != null) {
_injectAndGetInteractorBindings(session, accountId!);
}
WidgetsBinding.instance.addPostFrameCallback((_) {
_handleOpenEmailDetailedView();
});
ever<PresentationEmail?>(
mailboxDashBoardController.selectedEmail,
_handleOpenEmailDetailedView
);
ever(mailboxDashBoardController.emailUIAction, (action) {
obxListeners.add(ever(mailboxDashBoardController.emailUIAction, (action) {
if (action is CloseEmailDetailedViewToRedirectToTheInboxAction) {
if (emailSupervisorController.supportedPageView.isTrue) {
emailSupervisorController.popEmailQueue(_currentEmailId);
emailSupervisorController.setCurrentEmailIndex(-1);
emailSupervisorController.disposePageViewController();
}
_updateCurrentEmailId(null);
_resetToOriginalValue(isEmailClosing: true);
mailboxDashBoardController.clearSelectedEmail();
mailboxDashBoardController.dispatchRoute(DashboardRoutes.thread);
@@ -392,42 +389,54 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
} else if (action is ShowEmailContentViewAction) {
isEmailContentHidden.value = false;
mailboxDashBoardController.clearEmailUIAction();
} else if (action is PerformEmailActionInThreadDetailAction) {
if (action.presentationEmail.id != _currentEmailId) return;
pressEmailAction(
action.emailActionType,
action.presentationEmail,
);
} else if (action is CloseEmailInThreadDetailAction) {
if (action.emailId != _currentEmailId) return;
closeEmailView(context: currentContext);
for (var worker in obxListeners) {
worker.dispose();
}
Get.delete<SingleEmailController>(tag: _currentEmailId?.id.value);
}
});
}));
ever(mailboxDashBoardController.viewState, (viewState) {
obxListeners.add(ever(mailboxDashBoardController.viewState, (viewState) {
viewState.map((success) {
if (success is UnsubscribeEmailSuccess) {
emailUnsubscribe.value = null;
}
});
});
}));
if (_threadDetailController != null) {
obxListeners.add(ever(
_threadDetailController!.currentExpandedEmailId,
(emailId) {
if (emailId == null || emailId != _currentEmailId) return;
_threadDetailController!.currentEmailLoaded.value = currentEmailLoaded.value;
},
));
}
}
bool isListEmailContainSelectedEmail(PresentationEmail selectedEmail) {
return emailSupervisorController.currentListEmail.isNotEmpty
&& emailSupervisorController.currentListEmail.listEmailIds.contains(selectedEmail.id);
}
void _handleOpenEmailDetailedView(PresentationEmail? selectedEmail) {
if (selectedEmail == null || _currentEmailId == selectedEmail.id) {
void _handleOpenEmailDetailedView() {
if (currentEmail == null) {
log('SingleEmailController::_handleOpenEmailDetailedView(): email unselected');
return;
}
emailLoadedViewState.value = Right<Failure, Success>(GetEmailContentLoading());
emailSupervisorController.updateNewCurrentListEmail();
_updateCurrentEmailId(selectedEmail.id);
_resetToOriginalValue();
if (isListEmailContainSelectedEmail(selectedEmail)) {
_createMultipleEmailViewAsPageView(selectedEmail.id!);
} else {
_createSingleEmailView(selectedEmail.id!);
}
_createSingleEmailView(currentEmail!.id!);
if (!selectedEmail.hasRead) {
markAsEmailRead(selectedEmail, ReadActions.markAsRead, MarkReadAction.tap);
if (!currentEmail!.hasRead) {
markAsEmailRead(currentEmail!, ReadActions.markAsRead, MarkReadAction.tap);
}
if (mailboxDashBoardController.listIdentities.isEmpty) {
@@ -437,20 +446,8 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
}
void _updateCurrentEmailId(EmailId? emailId) {
_currentEmailId = emailId;
}
void _createMultipleEmailViewAsPageView(EmailId emailId) {
log('SingleEmailController::_createMultipleEmailViewAsPageView():');
emailSupervisorController.supportedPageView.value = true;
emailSupervisorController.createPageControllerAndJumpToEmailById(emailId);
_getEmailContentAction(emailId);
}
void _createSingleEmailView(EmailId emailId) {
log('SingleEmailController::_createSingleEmailView():');
emailSupervisorController.supportedPageView.value = false;
_getEmailContentAction(emailId);
}
@@ -461,7 +458,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
(failure) => null,
(success) {
if (success is StartDownloadAttachmentForWeb && !success.previewerSupported) {
emailSupervisorController.mailboxDashBoardController.addDownloadTask(
mailboxDashBoardController.addDownloadTask(
DownloadTaskState(
taskId: success.taskId,
attachment: success.attachment,
@@ -480,7 +477,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final percent = success.progress.round();
log('SingleEmailController::DownloadingAttachmentForWeb(): $percent%');
emailSupervisorController.mailboxDashBoardController.updateDownloadTask(
mailboxDashBoardController.updateDownloadTask(
success.taskId,
(currentTask) {
final newTask = currentTask.copyWith(
@@ -491,7 +488,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
return newTask;
});
} else if (success is StartDownloadAllAttachmentsForWeb) {
emailSupervisorController.mailboxDashBoardController.addDownloadTask(
mailboxDashBoardController.addDownloadTask(
DownloadTaskState(
taskId: success.taskId,
attachment: success.attachment,
@@ -510,7 +507,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final percent = success.progress.round();
log('SingleEmailController::DownloadingAttachmentForWeb(): $percent%');
emailSupervisorController.mailboxDashBoardController.updateDownloadTask(
mailboxDashBoardController.updateDownloadTask(
success.taskId,
(currentTask) {
final newTask = currentTask.copyWith(
@@ -590,59 +587,42 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _getEmailContentAction(EmailId emailId) {
final emailLoaded = emailSupervisorController.getEmailInQueueByEmailId(emailId);
if (session != null && accountId != null) {
try {
final baseDownloadUrl = session!.getDownloadUrl(jmapUrl: dynamicUrlInterceptors.jmapUrl);
TransformConfiguration transformConfiguration = PlatformInfo.isWeb
? TransformConfiguration.forPreviewEmailOnWeb()
: TransformConfiguration.forPreviewEmail();
if (emailLoaded != null) {
consumeState(Stream.value(Right<Failure, Success>(
GetEmailContentSuccess(
htmlEmailContent: emailLoaded.htmlContent,
attachments: emailLoaded.attachments,
inlineImages: emailLoaded.inlineImages,
emailCurrent: emailLoaded.emailCurrent
)
)));
} else {
if (session != null && accountId != null) {
try {
final baseDownloadUrl = session!.getDownloadUrl(jmapUrl: dynamicUrlInterceptors.jmapUrl);
TransformConfiguration transformConfiguration = PlatformInfo.isWeb
? TransformConfiguration.forPreviewEmailOnWeb()
: TransformConfiguration.forPreviewEmail();
consumeState(_getEmailContentInteractor.execute(
session!,
accountId!,
emailId,
baseDownloadUrl,
transformConfiguration
));
} catch (e) {
logError('SingleEmailController::_getEmailContentAction(): $e');
consumeState(Stream.value(Left(GetEmailContentFailure(
e,
onRetry: e is UnknownUriException
? null
: _getEmailContentInteractor.execute(
session!,
accountId!,
emailId,
session!.getDownloadUrl(jmapUrl: dynamicUrlInterceptors.jmapUrl),
PlatformInfo.isWeb
? TransformConfiguration.forPreviewEmailOnWeb()
: TransformConfiguration.forPreviewEmail(),
),
))));
}
consumeState(_getEmailContentInteractor.execute(
session!,
accountId!,
emailId,
baseDownloadUrl,
transformConfiguration
));
} catch (e) {
logError('SingleEmailController::_getEmailContentAction(): $e');
consumeState(Stream.value(Left(GetEmailContentFailure(
e,
onRetry: e is UnknownUriException
? null
: _getEmailContentInteractor.execute(
session!,
accountId!,
emailId,
session!.getDownloadUrl(jmapUrl: dynamicUrlInterceptors.jmapUrl),
PlatformInfo.isWeb
? TransformConfiguration.forPreviewEmailOnWeb()
: TransformConfiguration.forPreviewEmail(),
),
))));
}
}
}
void _getEmailContentOfflineSuccess(GetEmailContentFromCacheSuccess success) {
emailLoadedViewState.value = Right<Failure, Success>(success);
if (emailSupervisorController.presentationEmailsLoaded.length > ThreadConstants.defaultLimit.value.toInt()) {
emailSupervisorController.popFirstEmailQueue();
}
emailSupervisorController.popEmailQueue(success.emailCurrent.id);
currentEmailLoaded.value = EmailLoaded(
htmlContent: success.htmlEmailContent,
@@ -650,7 +630,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
inlineImages: List.of(success.inlineImages ?? []),
emailCurrent: success.emailCurrent,
);
emailSupervisorController.pushEmailQueue(currentEmailLoaded.value!);
_threadDetailController?.currentEmailLoaded.value = currentEmailLoaded.value;
if (success.emailCurrent.id == currentEmail?.id) {
attachments.value = success.attachments ?? [];
@@ -683,10 +663,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _getEmailContentSuccess(GetEmailContentSuccess success) {
emailLoadedViewState.value = Right<Failure, Success>(success);
if (emailSupervisorController.presentationEmailsLoaded.length > ThreadConstants.defaultLimit.value.toInt()) {
emailSupervisorController.popFirstEmailQueue();
}
emailSupervisorController.popEmailQueue(success.emailCurrent?.id);
currentEmailLoaded.value = EmailLoaded(
htmlContent: success.htmlEmailContent,
@@ -694,7 +670,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
inlineImages: List.of(success.inlineImages ?? []),
emailCurrent: success.emailCurrent,
);
emailSupervisorController.pushEmailQueue(currentEmailLoaded.value!);
_threadDetailController?.currentEmailLoaded.value = currentEmailLoaded.value;
if (success.emailCurrent?.id == currentEmail?.id) {
attachments.value = success.attachments ?? [];
@@ -745,6 +721,14 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
emailUnsubscribe.value = null;
}
}
if ((_threadDetailController?.emailIdsPresentation.keys.length ?? 0) > 1 == true) {
_jumpScrollViewToTopOfEmail();
}
}
void _jumpScrollViewToTopOfEmail() {
if (_currentEmailId == null) return;
_threadDetailController?.focusExpandedEmail(_currentEmailId!);
}
void _handleUnsubscribe(String listUnsubscribe) {
@@ -809,9 +793,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void _handleMarkAsEmailReadCompleted(ReadActions readActions) {
if (_currentEmailId != null) {
if (currentEmail?.id != null) {
mailboxDashBoardController.updateEmailFlagByEmailIds(
[_currentEmailId!],
[currentEmail!.id!],
readAction: readActions,
);
}
@@ -952,7 +936,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
final downloadAllSupported = session!.isDownloadAllSupported(accountId);
if (!downloadAllSupported || _currentEmailId == null) {
if (!downloadAllSupported) {
consumeState(Stream.value(Left(ExportAllAttachmentsFailure())));
return;
}
@@ -960,7 +944,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final baseDownloadAllUrl = session!.getDownloadAllCapability(accountId)!.endpoint!;
consumeState(_exportAllAttachmentsInteractor.execute(
accountId!,
_currentEmailId!,
currentEmail!.id!,
baseDownloadAllUrl,
outputFileName,
cancelToken: cancelToken,
@@ -1071,7 +1055,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
final downloadAllSupported = session.isDownloadAllSupported(accountId);
final emailId = _currentEmailId;
final emailId = currentEmail?.id;
if (!downloadAllSupported || emailId == null) {
consumeState(Stream.value(Left(DownloadAllAttachmentsForWebFailure(
@@ -1454,10 +1438,10 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
final newEmail = currentEmail?.updateKeywords({
KeyWordIdentifier.emailFlagged: success.markStarAction == MarkStarAction.markStar,
});
mailboxDashBoardController.setSelectedEmail(newEmail);
final emailId = newEmail?.id;
if (emailId == null) return;
_threadDetailController?.emailIdsPresentation[emailId] = newEmail;
mailboxDashBoardController.updateEmailFlagByEmailIds(
[emailId],
markStarAction: success.markStarAction,
@@ -1508,6 +1492,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
case EmailActionType.editAsNewEmail:
_editAsNewEmail(presentationEmail);
break;
case EmailActionType.reply:
_replyEmail(presentationEmail);
break;
default:
break;
}
@@ -1639,7 +1626,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
return;
}
if (currentEmail == null || _currentEmailId == null) {
if (currentEmail == null) {
appToast.showToastErrorMessage(
currentOverlayContext!,
AppLocalizations.of(context).toastMessageCannotFoundEmailIdWhenSendReceipt);
@@ -1700,16 +1687,12 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void closeEmailView({BuildContext? context}) {
if (emailSupervisorController.supportedPageView.isTrue) {
emailSupervisorController.popEmailQueue(_currentEmailId);
emailSupervisorController.setCurrentEmailIndex(-1);
emailSupervisorController.disposePageViewController();
}
mailboxDashBoardController.clearSelectedEmail();
_updateCurrentEmailId(null);
_resetToOriginalValue(isEmailClosing: true);
_replaceBrowserHistory();
if (mailboxDashBoardController.searchController.isSearchEmailRunning) {
if (mailboxDashBoardController.searchController.isSearchEmailRunning
|| getBinding<SearchEmailController>()?.searchIsRunning.value == true
) {
if (context != null && responsiveUtils.isWebDesktop(context)) {
mailboxDashBoardController.dispatchRoute(DashboardRoutes.thread);
} else {
@@ -1723,8 +1706,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
}
bool get isOpenEmailNotMailboxFromRoute => emailSupervisorController.supportedPageView.isFalse
&& mailboxDashBoardController.selectedMailbox.value == null;
bool get isOpenEmailNotMailboxFromRoute => mailboxDashBoardController.selectedMailbox.value == null;
void _replaceBrowserHistory() {
if (PlatformInfo.isWeb) {
@@ -1761,17 +1743,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
mailboxDashBoardController.openComposer(ComposerArguments());
break;
case EmailActionType.reply:
mailboxDashBoardController.openComposer(
ComposerArguments.replyEmail(
presentationEmail: presentationEmail,
content: currentEmailLoaded.value?.htmlContent ?? '',
inlineImages: currentEmailLoaded.value?.inlineImages ?? [],
mailboxRole: presentationEmail.mailboxContain?.role,
messageId: currentEmailLoaded.value?.emailCurrent?.messageId,
references: currentEmailLoaded.value?.emailCurrent?.references,
listPost: currentEmailLoaded.value?.emailCurrent?.listPost,
)
);
_replyEmail(presentationEmail);
break;
case EmailActionType.replyToList:
log('SingleEmailController::pressEmailAction:replyToList');
@@ -1860,15 +1832,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
}
void toggleScrollPhysicsPagerView(bool leftDirection) {
log('SingleEmailController::toggleScrollPhysicsPagerView():leftDirection: $leftDirection');
if (leftDirection) {
emailSupervisorController.moveToNextEmail();
} else {
emailSupervisorController.backToPreviousEmail();
}
}
void _storeOpenedEmailAction(Session? session, AccountId? accountId, DetailedEmail detailedEmail) async {
if (session != null && accountId != null) {
consumeState(_storeOpenedEmailInteractor.execute(session, accountId, detailedEmail));
@@ -1913,9 +1876,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
void _handleParseCalendarEventSuccess(ParseCalendarEventSuccess success) {
emailLoadedViewState.value = Right<Failure, Success>(success);
blobCalendarEvent.value = success.blobCalendarEventList.firstOrNull;
if (PlatformInfo.isMobile) {
_enableScrollPageView();
}
updateAttendanceStatus(success);
}
@@ -1924,10 +1884,6 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
emailContents.value = currentEmailLoaded.value?.htmlContent;
}
void _enableScrollPageView() {
emailSupervisorController.scrollPhysicsPageView.value = null;
}
void openNewTabAction(String link) {
AppUtils.launchLink(link);
}
@@ -1938,8 +1894,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
}
void openAttachmentList(BuildContext context, List<Attachment> attachments) {
final tag = _currentEmailId?.id.value;
if (responsiveUtils.isMobile(context)) {
(AttachmentListBottomSheetBuilder(context, attachments, imagePaths, _attachmentListScrollController)
(AttachmentListBottomSheetBuilder(context, attachments, imagePaths, _attachmentListScrollController, tag)
..onCloseButtonAction(() => popBack())
..onDownloadAttachmentFileAction((attachment) => handleDownloadAttachmentAction(context, attachment))
..onViewAttachmentFileAction((attachment) => handleViewAttachmentAction(context, attachment))
@@ -1963,6 +1920,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
onDownloadAllButtonAction: isDownloadAllSupported()
? () => downloadAllAttachmentsForWeb('TwakeMail-${DateTime.now()}')
: null,
singleEmailControllerTag: tag,
)
),
barrierColor: AppColor.colorDefaultCupertinoActionSheet,
@@ -2240,6 +2198,20 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
);
}
void _replyEmail(PresentationEmail presentationEmail) {
mailboxDashBoardController.openComposer(
ComposerArguments.replyEmail(
presentationEmail: presentationEmail,
content: currentEmailLoaded.value?.htmlContent ?? '',
inlineImages: currentEmailLoaded.value?.inlineImages ?? [],
mailboxRole: presentationEmail.mailboxContain?.role,
messageId: currentEmailLoaded.value?.emailCurrent?.messageId,
references: currentEmailLoaded.value?.emailCurrent?.references,
listPost: currentEmailLoaded.value?.emailCurrent?.listPost,
)
);
}
void handleDownloadAttachmentAction(
BuildContext context,
Attachment attachment,