TF-4384 Fix page not found 404 error when refreshing label views (#4390)
This commit is contained in:
@@ -82,6 +82,7 @@ import 'package:tmail_ui_user/features/email/presentation/utils/email_action_rea
|
|||||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||||
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart';
|
import 'package:tmail_ui_user/features/home/domain/extensions/session_extensions.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/action/mailbox_ui_action.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/action/mailbox_ui_action.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/action/download_ui_action.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/action/download_ui_action.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/controller/mailbox_dashboard_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_download_attachment_extension.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/handle_download_attachment_extension.dart';
|
||||||
@@ -1069,18 +1070,19 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
|||||||
|
|
||||||
void _replaceBrowserHistory() {
|
void _replaceBrowserHistory() {
|
||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
final selectedMailboxId = mailboxDashBoardController.selectedMailbox.value?.id;
|
final selectedMailbox = mailboxDashBoardController.selectedMailbox.value;
|
||||||
final isSearchRunning = mailboxDashBoardController.searchController.isSearchEmailRunning;
|
final isSearchRunning = mailboxDashBoardController.searchController.isSearchEmailRunning;
|
||||||
RouteUtils.replaceBrowserHistory(
|
RouteUtils.replaceBrowserHistory(
|
||||||
title: isSearchRunning
|
title: isSearchRunning
|
||||||
? 'SearchEmail'
|
? 'SearchEmail'
|
||||||
: 'Mailbox-${selectedMailboxId?.id.value}',
|
: selectedMailbox?.browserRouteTitle ?? '',
|
||||||
url: RouteUtils.createUrlWebLocationBar(
|
url: RouteUtils.createUrlWebLocationBar(
|
||||||
AppRoutes.dashboard,
|
AppRoutes.dashboard,
|
||||||
router: NavigationRouter(
|
router: NavigationRouter(
|
||||||
mailboxId: isSearchRunning
|
mailboxId: isSearchRunning
|
||||||
? null
|
? null
|
||||||
: selectedMailboxId,
|
: selectedMailbox?.browserRouteMailboxId,
|
||||||
|
labelId: selectedMailbox?.labelId,
|
||||||
dashboardType: isSearchRunning
|
dashboardType: isSearchRunning
|
||||||
? DashboardType.search
|
? DashboardType.search
|
||||||
: DashboardType.normal,
|
: DashboardType.normal,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:core/presentation/state/failure.dart';
|
|||||||
import 'package:core/presentation/state/success.dart';
|
import 'package:core/presentation/state/success.dart';
|
||||||
import 'package:core/utils/app_logger.dart';
|
import 'package:core/utils/app_logger.dart';
|
||||||
import 'package:dartz/dartz.dart' hide State;
|
import 'package:dartz/dartz.dart' hide State;
|
||||||
|
import 'package:flutter/material.dart' hide State;
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
@@ -38,6 +39,8 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
|||||||
final labels = <Label>[].obs;
|
final labels = <Label>[].obs;
|
||||||
final labelListExpandMode = Rx(ExpandMode.EXPAND);
|
final labelListExpandMode = Rx(ExpandMode.EXPAND);
|
||||||
final isLabelSettingEnabled = RxBool(false);
|
final isLabelSettingEnabled = RxBool(false);
|
||||||
|
final isLabelsLoaded = RxBool(false);
|
||||||
|
final GlobalKey labelAppBarKey = GlobalKey();
|
||||||
|
|
||||||
GetAllLabelInteractor? _getAllLabelInteractor;
|
GetAllLabelInteractor? _getAllLabelInteractor;
|
||||||
CreateNewLabelInteractor? _createNewLabelInteractor;
|
CreateNewLabelInteractor? _createNewLabelInteractor;
|
||||||
@@ -72,11 +75,17 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
|||||||
isLabelSettingEnabled.value = false;
|
isLabelSettingEnabled.value = false;
|
||||||
isLabelSettingEnabled.refresh();
|
isLabelSettingEnabled.refresh();
|
||||||
_clearLabelData();
|
_clearLabelData();
|
||||||
|
setLabelLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLabelLoaded() {
|
||||||
|
isLabelsLoaded.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
void _clearLabelData() {
|
void _clearLabelData() {
|
||||||
labels.clear();
|
labels.clear();
|
||||||
|
isLabelsLoaded.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void injectLabelsBindings() {
|
void injectLabelsBindings() {
|
||||||
@@ -114,7 +123,11 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getAllLabels(AccountId accountId) {
|
void getAllLabels(AccountId accountId) {
|
||||||
if (_getAllLabelInteractor == null) return;
|
if (_getAllLabelInteractor == null) {
|
||||||
|
labels.value = [];
|
||||||
|
setLabelLoaded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
consumeState(_getAllLabelInteractor!.execute(accountId));
|
consumeState(_getAllLabelInteractor!.execute(accountId));
|
||||||
}
|
}
|
||||||
@@ -173,6 +186,9 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
|||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
injectLabelsBindings();
|
injectLabelsBindings();
|
||||||
getAllLabels(accountId);
|
getAllLabels(accountId);
|
||||||
|
} else {
|
||||||
|
_clearLabelData();
|
||||||
|
setLabelLoaded();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +197,7 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
|||||||
if (success is GetAllLabelSuccess) {
|
if (success is GetAllLabelSuccess) {
|
||||||
labels.value = success.labels..sortByAlphabetically();
|
labels.value = success.labels..sortByAlphabetically();
|
||||||
setCurrentLabelState(success.newState);
|
setCurrentLabelState(success.newState);
|
||||||
|
setLabelLoaded();
|
||||||
} else if (success is CreateNewLabelSuccess) {
|
} else if (success is CreateNewLabelSuccess) {
|
||||||
_handleCreateNewLabelSuccess(success);
|
_handleCreateNewLabelSuccess(success);
|
||||||
} else if (success is GetLabelSettingStateSuccess) {
|
} else if (success is GetLabelSettingStateSuccess) {
|
||||||
@@ -198,12 +215,14 @@ class LabelController extends BaseController with LabelContextMenuMixin {
|
|||||||
void handleFailureViewState(Failure failure) {
|
void handleFailureViewState(Failure failure) {
|
||||||
if (failure is GetAllLabelFailure) {
|
if (failure is GetAllLabelFailure) {
|
||||||
labels.value = [];
|
labels.value = [];
|
||||||
|
setLabelLoaded();
|
||||||
} else if (failure is CreateNewLabelFailure) {
|
} else if (failure is CreateNewLabelFailure) {
|
||||||
_handleCreateNewLabelFailure(failure);
|
_handleCreateNewLabelFailure(failure);
|
||||||
} else if (failure is GetLabelSettingStateFailure) {
|
} else if (failure is GetLabelSettingStateFailure) {
|
||||||
isLabelSettingEnabled.value = false;
|
isLabelSettingEnabled.value = false;
|
||||||
isLabelSettingEnabled.refresh();
|
isLabelSettingEnabled.refresh();
|
||||||
_clearLabelData();
|
_clearLabelData();
|
||||||
|
setLabelLoaded();
|
||||||
} else if (failure is EditLabelFailure) {
|
} else if (failure is EditLabelFailure) {
|
||||||
handleEditLabelFailure(failure);
|
handleEditLabelFailure(failure);
|
||||||
} else if (failure is DeleteALabelFailure) {
|
} else if (failure is DeleteALabelFailure) {
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ abstract class BaseMailboxView extends GetWidget<MailboxController>
|
|||||||
final countLabels = labelController.labels.length;
|
final countLabels = labelController.labels.length;
|
||||||
|
|
||||||
return LabelsBarWidget(
|
return LabelsBarWidget(
|
||||||
|
key: labelController.labelAppBarKey,
|
||||||
imagePaths: controller.imagePaths,
|
imagePaths: controller.imagePaths,
|
||||||
isDesktop: isDesktop,
|
isDesktop: isDesktop,
|
||||||
height: isDesktop ? 48 : 40,
|
height: isDesktop ? 48 : 40,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
import 'package:core/utils/platform_info.dart';
|
import 'package:core/utils/platform_info.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
import 'package:labels/model/label.dart';
|
import 'package:labels/model/label.dart';
|
||||||
import 'package:tmail_ui_user/features/labels/presentation/extensions/handle_label_action_type_extension.dart';
|
import 'package:tmail_ui_user/features/labels/presentation/extensions/handle_label_action_type_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
|
import 'package:tmail_ui_user/features/labels/presentation/models/label_action_type.dart';
|
||||||
@@ -64,4 +65,22 @@ extension HandleLabelActionTypeExtension on MailboxDashBoardController {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Label? getLabelById(Id labelId) {
|
||||||
|
return labelController.labels
|
||||||
|
.where((label) => label.id == labelId)
|
||||||
|
.firstOrNull;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scrollToLabelListView() {
|
||||||
|
final context = labelController.labelAppBarKey.currentContext;
|
||||||
|
if (context == null) return;
|
||||||
|
|
||||||
|
Scrollable.ensureVisible(
|
||||||
|
context,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.easeOut,
|
||||||
|
alignment: 0.5,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,104 @@
|
|||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:get/get_rx/src/rx_workers/rx_workers.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/handle_label_action_type_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/mailbox_controller.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/presentation_label_mailbox.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/extensions/labels/handle_logic_label_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||||
|
import 'package:tmail_ui_user/main/routes/navigation_router.dart';
|
||||||
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
|
|
||||||
|
extension HandleNavigationExtension on MailboxController {
|
||||||
|
void handleLabelNavigation(NavigationRouter router, Id labelId) {
|
||||||
|
if (!_isLabelCapabilityValid()) {
|
||||||
|
_navigateToUnknown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_isLabelsReady()) {
|
||||||
|
_waitForLabelsLoaded(() {
|
||||||
|
_handleLabelNavigationInternal(router, labelId);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_handleLabelNavigationInternal(router, labelId);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isLabelCapabilityValid() {
|
||||||
|
return mailboxDashBoardController.isLabelCapabilitySupported;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isLabelsReady() {
|
||||||
|
return mailboxDashBoardController.labelController.isLabelsLoaded.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _waitForLabelsLoaded(VoidCallback onLoaded) {
|
||||||
|
isLabelsLoadedWorker?.dispose();
|
||||||
|
isLabelsLoadedWorker = null;
|
||||||
|
|
||||||
|
final observable = mailboxDashBoardController.labelController.isLabelsLoaded;
|
||||||
|
|
||||||
|
if (observable.value) {
|
||||||
|
onLoaded();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isLabelsLoadedWorker = ever(
|
||||||
|
observable,
|
||||||
|
(isLoaded) {
|
||||||
|
try {
|
||||||
|
if (!isLoaded) return;
|
||||||
|
_completeLabelsLoaded(onLoaded);
|
||||||
|
} catch (e) {
|
||||||
|
logWarning('HandleNavigationExtension::_waitForLabelsLoaded: Exception: $e');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _completeLabelsLoaded(VoidCallback onLoaded) {
|
||||||
|
final worker = isLabelsLoadedWorker;
|
||||||
|
if (worker == null) return;
|
||||||
|
|
||||||
|
isLabelsLoadedWorker = null;
|
||||||
|
worker.dispose();
|
||||||
|
|
||||||
|
if (!isClosed) {
|
||||||
|
onLoaded();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleLabelNavigationInternal(
|
||||||
|
NavigationRouter router,
|
||||||
|
Id labelId,
|
||||||
|
) {
|
||||||
|
final matchedLabel = mailboxDashBoardController.getLabelById(labelId);
|
||||||
|
|
||||||
|
if (matchedLabel == null) {
|
||||||
|
_navigateToUnknown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final labelMailbox = PresentationLabelMailbox.initial(matchedLabel);
|
||||||
|
|
||||||
|
if (router.emailId != null) {
|
||||||
|
openEmailInsideMailboxFromLocationBar(
|
||||||
|
labelMailbox,
|
||||||
|
router.emailId!,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
openMailboxFromLocationBar(labelMailbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
mailboxDashBoardController.scrollToLabelListView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _navigateToUnknown() {
|
||||||
|
clearNavigationRouter();
|
||||||
|
popAndPush(AppRoutes.unknownRoutePage);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
|
|
||||||
import 'package:core/presentation/resources/image_paths.dart';
|
import 'package:core/presentation/resources/image_paths.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/keyword_identifier.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||||
import 'package:labels/extensions/label_extension.dart';
|
import 'package:labels/extensions/label_extension.dart';
|
||||||
|
import 'package:model/extensions/mailbox_id_extension.dart';
|
||||||
import 'package:model/extensions/presentation_mailbox_extension.dart';
|
import 'package:model/extensions/presentation_mailbox_extension.dart';
|
||||||
import 'package:model/mailbox/presentation_mailbox.dart';
|
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/presentation_label_mailbox.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/presentation_label_mailbox.dart';
|
||||||
@@ -160,4 +163,13 @@ extension PresentationMailboxExtension on PresentationMailbox {
|
|||||||
bool get isCacheable => !isVirtualFolder && this is! PresentationLabelMailbox;
|
bool get isCacheable => !isVirtualFolder && this is! PresentationLabelMailbox;
|
||||||
|
|
||||||
bool get isLabelMailbox => this is PresentationLabelMailbox;
|
bool get isLabelMailbox => this is PresentationLabelMailbox;
|
||||||
|
|
||||||
|
String get browserRouteTitle => isLabelMailbox
|
||||||
|
? 'Label-${(this as PresentationLabelMailbox).label.id?.value}'
|
||||||
|
: 'Mailbox-${mailboxId?.asString}';
|
||||||
|
|
||||||
|
Id? get labelId =>
|
||||||
|
isLabelMailbox ? (this as PresentationLabelMailbox).label.id : null;
|
||||||
|
|
||||||
|
MailboxId? get browserRouteMailboxId => isLabelMailbox ? null : mailboxId;
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,7 @@ import 'package:tmail_ui_user/features/mailbox/domain/usecases/subscribe_mailbox
|
|||||||
import 'package:tmail_ui_user/features/mailbox/domain/usecases/subscribe_multiple_mailbox_interactor.dart';
|
import 'package:tmail_ui_user/features/mailbox/domain/usecases/subscribe_multiple_mailbox_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/action/mailbox_ui_action.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/action/mailbox_ui_action.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/handle_action_required_tab_extension.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/handle_action_required_tab_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/handle_navigation_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/mixin/mailbox_widget_mixin.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/mixin/mailbox_widget_mixin.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
||||||
@@ -133,6 +134,7 @@ class MailboxController extends BaseMailboxController
|
|||||||
MailboxId? _newFolderId;
|
MailboxId? _newFolderId;
|
||||||
NavigationRouter? _navigationRouter;
|
NavigationRouter? _navigationRouter;
|
||||||
WebSocketQueueHandler? _webSocketQueueHandler;
|
WebSocketQueueHandler? _webSocketQueueHandler;
|
||||||
|
Worker? isLabelsLoadedWorker;
|
||||||
|
|
||||||
final _openMailboxEventController = StreamController<OpenMailboxViewEvent>();
|
final _openMailboxEventController = StreamController<OpenMailboxViewEvent>();
|
||||||
StreamSubscription? _openMailboxEventStreamSubscription;
|
StreamSubscription? _openMailboxEventStreamSubscription;
|
||||||
@@ -198,6 +200,8 @@ class MailboxController extends BaseMailboxController
|
|||||||
_openMailboxEventController.close();
|
_openMailboxEventController.close();
|
||||||
mailboxListScrollController.dispose();
|
mailboxListScrollController.dispose();
|
||||||
_webSocketQueueHandler?.dispose();
|
_webSocketQueueHandler?.dispose();
|
||||||
|
isLabelsLoadedWorker?.dispose();
|
||||||
|
isLabelsLoadedWorker = null;
|
||||||
super.onClose();
|
super.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -787,7 +791,9 @@ class MailboxController extends BaseMailboxController
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DashboardType.normal:
|
case DashboardType.normal:
|
||||||
if (_navigationRouter!.mailboxId != null) {
|
if (_navigationRouter!.labelId != null) {
|
||||||
|
handleLabelNavigation(_navigationRouter!, _navigationRouter!.labelId!);
|
||||||
|
} else if (_navigationRouter!.mailboxId != null) {
|
||||||
final matchedMailboxNode = findMailboxNodeById(_navigationRouter!.mailboxId!);
|
final matchedMailboxNode = findMailboxNodeById(_navigationRouter!.mailboxId!);
|
||||||
if (matchedMailboxNode != null) {
|
if (matchedMailboxNode != null) {
|
||||||
if (_navigationRouter!.emailId != null) {
|
if (_navigationRouter!.emailId != null) {
|
||||||
@@ -813,6 +819,11 @@ class MailboxController extends BaseMailboxController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openEmailInsideMailboxFromLocationBar(
|
||||||
|
PresentationMailbox presentationMailbox,
|
||||||
|
EmailId emailId
|
||||||
|
) => _openEmailInsideMailboxFromLocationBar(presentationMailbox, emailId);
|
||||||
|
|
||||||
void _openEmailInsideMailboxFromLocationBar(
|
void _openEmailInsideMailboxFromLocationBar(
|
||||||
PresentationMailbox presentationMailbox,
|
PresentationMailbox presentationMailbox,
|
||||||
EmailId emailId
|
EmailId emailId
|
||||||
@@ -822,15 +833,19 @@ class MailboxController extends BaseMailboxController
|
|||||||
_clearNavigationRouter();
|
_clearNavigationRouter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void openMailboxFromLocationBar(PresentationMailbox presentationMailbox) =>
|
||||||
|
_openMailboxFromLocationBar(presentationMailbox);
|
||||||
|
|
||||||
void _openMailboxFromLocationBar(PresentationMailbox presentationMailbox) {
|
void _openMailboxFromLocationBar(PresentationMailbox presentationMailbox) {
|
||||||
mailboxDashBoardController.setSelectedMailbox(presentationMailbox);
|
mailboxDashBoardController.setSelectedMailbox(presentationMailbox);
|
||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
RouteUtils.replaceBrowserHistory(
|
RouteUtils.replaceBrowserHistory(
|
||||||
title: 'Mailbox-${presentationMailbox.mailboxId?.id.value}',
|
title: presentationMailbox.browserRouteTitle,
|
||||||
url: RouteUtils.createUrlWebLocationBar(
|
url: RouteUtils.createUrlWebLocationBar(
|
||||||
AppRoutes.dashboard,
|
AppRoutes.dashboard,
|
||||||
router: NavigationRouter(
|
router: NavigationRouter(
|
||||||
mailboxId: presentationMailbox.mailboxId,
|
mailboxId: presentationMailbox.browserRouteMailboxId,
|
||||||
|
labelId: presentationMailbox.labelId,
|
||||||
dashboardType: DashboardType.normal
|
dashboardType: DashboardType.normal
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -868,6 +883,8 @@ class MailboxController extends BaseMailboxController
|
|||||||
_clearNavigationRouter();
|
_clearNavigationRouter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clearNavigationRouter() => _clearNavigationRouter();
|
||||||
|
|
||||||
void _clearNavigationRouter() {
|
void _clearNavigationRouter() {
|
||||||
_navigationRouter = null;
|
_navigationRouter = null;
|
||||||
}
|
}
|
||||||
@@ -1279,13 +1296,14 @@ class MailboxController extends BaseMailboxController
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _replaceBrowserHistory() {
|
void _replaceBrowserHistory() {
|
||||||
log('MailboxController::_replaceBrowserHistory:selectedMailbox: ${selectedMailbox?.id}');
|
final currentMailbox = selectedMailbox;
|
||||||
|
log('MailboxController::_replaceBrowserHistory:selectedMailbox: ${currentMailbox?.id.asString}');
|
||||||
if (PlatformInfo.isWeb && Get.currentRoute.startsWith(AppRoutes.dashboard)) {
|
if (PlatformInfo.isWeb && Get.currentRoute.startsWith(AppRoutes.dashboard)) {
|
||||||
final selectedMailboxId = selectedMailbox?.id;
|
|
||||||
final route = RouteUtils.createUrlWebLocationBar(
|
final route = RouteUtils.createUrlWebLocationBar(
|
||||||
AppRoutes.dashboard,
|
AppRoutes.dashboard,
|
||||||
router: NavigationRouter(
|
router: NavigationRouter(
|
||||||
mailboxId: selectedMailboxId,
|
mailboxId: currentMailbox?.browserRouteMailboxId,
|
||||||
|
labelId: currentMailbox?.labelId,
|
||||||
searchQuery: mailboxDashBoardController.searchController.isSearchEmailRunning
|
searchQuery: mailboxDashBoardController.searchController.isSearchEmailRunning
|
||||||
? mailboxDashBoardController.searchController.searchQuery
|
? mailboxDashBoardController.searchController.searchQuery
|
||||||
: null,
|
: null,
|
||||||
@@ -1295,7 +1313,7 @@ class MailboxController extends BaseMailboxController
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
RouteUtils.replaceBrowserHistory(
|
RouteUtils.replaceBrowserHistory(
|
||||||
title: 'Mailbox-${selectedMailboxId?.id.value}',
|
title: currentMailbox?.browserRouteTitle ?? '',
|
||||||
url: route
|
url: route
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -3064,7 +3064,7 @@ class MailboxDashBoardController extends ReloadableController
|
|||||||
void _replaceBrowserHistory({Uri? uri}) {
|
void _replaceBrowserHistory({Uri? uri}) {
|
||||||
log('MailboxDashBoardController::_replaceBrowserHistory:uri: $uri');
|
log('MailboxDashBoardController::_replaceBrowserHistory:uri: $uri');
|
||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
final selectedMailboxId = selectedMailbox.value?.id;
|
final currentMailbox = selectedMailbox.value;
|
||||||
final selectedEmailId = selectedEmail.value?.id;
|
final selectedEmailId = selectedEmail.value?.id;
|
||||||
final isSearchRunning = searchController.isSearchEmailRunning;
|
final isSearchRunning = searchController.isSearchEmailRunning;
|
||||||
String title = '';
|
String title = '';
|
||||||
@@ -3073,7 +3073,7 @@ class MailboxDashBoardController extends ReloadableController
|
|||||||
} else if (isSearchRunning) {
|
} else if (isSearchRunning) {
|
||||||
title = 'SearchEmail';
|
title = 'SearchEmail';
|
||||||
} else {
|
} else {
|
||||||
title = 'Mailbox-${selectedMailboxId?.asString}';
|
title = currentMailbox?.browserRouteTitle ?? '';
|
||||||
}
|
}
|
||||||
RouteUtils.replaceBrowserHistory(
|
RouteUtils.replaceBrowserHistory(
|
||||||
title: title,
|
title: title,
|
||||||
@@ -3083,7 +3083,8 @@ class MailboxDashBoardController extends ReloadableController
|
|||||||
emailId: selectedEmail.value?.id,
|
emailId: selectedEmail.value?.id,
|
||||||
mailboxId: isSearchRunning
|
mailboxId: isSearchRunning
|
||||||
? null
|
? null
|
||||||
: selectedMailboxId,
|
: currentMailbox?.browserRouteMailboxId,
|
||||||
|
labelId: currentMailbox?.labelId,
|
||||||
dashboardType: isSearchRunning
|
dashboardType: isSearchRunning
|
||||||
? DashboardType.search
|
? DashboardType.search
|
||||||
: DashboardType.normal,
|
: DashboardType.normal,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import 'package:tmail_ui_user/features/email/domain/state/move_to_mailbox_state.
|
|||||||
import 'package:tmail_ui_user/features/email/presentation/action/email_ui_action.dart';
|
import 'package:tmail_ui_user/features/email/presentation/action/email_ui_action.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
import 'package:tmail_ui_user/features/email/presentation/utils/email_utils.dart';
|
||||||
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
|
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
import 'package:tmail_ui_user/features/mailbox/presentation/model/mailbox_actions.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/model/recent_search.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/model/recent_search.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_all_recent_search_latest_state.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_all_recent_search_latest_state.dart';
|
||||||
@@ -895,12 +896,14 @@ class SearchEmailController extends BaseController
|
|||||||
mailboxDashBoardController.searchController.disableAllSearchEmail();
|
mailboxDashBoardController.searchController.disableAllSearchEmail();
|
||||||
mailboxDashBoardController.dispatchRoute(DashboardRoutes.thread);
|
mailboxDashBoardController.dispatchRoute(DashboardRoutes.thread);
|
||||||
if (PlatformInfo.isWeb) {
|
if (PlatformInfo.isWeb) {
|
||||||
|
final currentMailbox = mailboxDashBoardController.selectedMailbox.value;
|
||||||
RouteUtils.replaceBrowserHistory(
|
RouteUtils.replaceBrowserHistory(
|
||||||
title: 'Mailbox-${mailboxDashBoardController.selectedMailbox.value?.id.id.value}',
|
title: currentMailbox?.browserRouteTitle ?? '',
|
||||||
url: RouteUtils.createUrlWebLocationBar(
|
url: RouteUtils.createUrlWebLocationBar(
|
||||||
AppRoutes.dashboard,
|
AppRoutes.dashboard,
|
||||||
router: NavigationRouter(
|
router: NavigationRouter(
|
||||||
mailboxId: mailboxDashBoardController.selectedMailbox.value?.id,
|
mailboxId: currentMailbox?.browserRouteMailboxId,
|
||||||
|
labelId: currentMailbox?.labelId,
|
||||||
dashboardType: DashboardType.normal
|
dashboardType: DashboardType.normal
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:model/email/presentation_email.dart';
|
|||||||
import 'package:model/extensions/presentation_email_extension.dart';
|
import 'package:model/extensions/presentation_email_extension.dart';
|
||||||
import 'package:model/mailbox/presentation_mailbox.dart';
|
import 'package:model/mailbox/presentation_mailbox.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/extensions/email_extension.dart';
|
import 'package:tmail_ui_user/features/email/presentation/extensions/email_extension.dart';
|
||||||
|
import 'package:tmail_ui_user/features/mailbox/presentation/extensions/presentation_mailbox_extension.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||||
import 'package:tmail_ui_user/features/thread_detail/domain/model/email_in_thread_detail_info.dart';
|
import 'package:tmail_ui_user/features/thread_detail/domain/model/email_in_thread_detail_info.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||||
@@ -48,7 +49,10 @@ extension ListPresentationEmailExtensions on List<PresentationEmail> {
|
|||||||
AppRoutes.dashboard,
|
AppRoutes.dashboard,
|
||||||
router: NavigationRouter(
|
router: NavigationRouter(
|
||||||
emailId: currentEmail.id,
|
emailId: currentEmail.id,
|
||||||
mailboxId: isSearchEmailRunning ? null : selectedMailbox?.id,
|
mailboxId: isSearchEmailRunning
|
||||||
|
? null
|
||||||
|
: selectedMailbox?.browserRouteMailboxId,
|
||||||
|
labelId: selectedMailbox?.labelId,
|
||||||
searchQuery: isSearchEmailRunning ? searchQuery : null,
|
searchQuery: isSearchEmailRunning ? searchQuery : null,
|
||||||
dashboardType: isSearchEmailRunning ? DashboardType.search : DashboardType.normal
|
dashboardType: isSearchEmailRunning ? DashboardType.search : DashboardType.normal
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1469,7 +1469,8 @@ class ThreadController extends BaseController with EmailActionController {
|
|||||||
AppRoutes.dashboard,
|
AppRoutes.dashboard,
|
||||||
router: NavigationRouter(
|
router: NavigationRouter(
|
||||||
emailId: email.id,
|
emailId: email.id,
|
||||||
mailboxId: mailboxContain.mailboxId,
|
mailboxId: mailboxContain.browserRouteMailboxId,
|
||||||
|
labelId: mailboxContain.labelId,
|
||||||
dashboardType: DashboardType.normal
|
dashboardType: DashboardType.normal
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
import 'package:equatable/equatable.dart';
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email_address.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||||
@@ -14,6 +15,7 @@ enum DashboardType {
|
|||||||
class NavigationRouter with EquatableMixin {
|
class NavigationRouter with EquatableMixin {
|
||||||
final EmailId? emailId;
|
final EmailId? emailId;
|
||||||
final MailboxId? mailboxId;
|
final MailboxId? mailboxId;
|
||||||
|
final Id? labelId;
|
||||||
final DashboardType dashboardType;
|
final DashboardType dashboardType;
|
||||||
final SearchQuery? searchQuery;
|
final SearchQuery? searchQuery;
|
||||||
final String? routeName;
|
final String? routeName;
|
||||||
@@ -36,7 +38,11 @@ class NavigationRouter with EquatableMixin {
|
|||||||
this.accountMenuItem = AccountMenuItem.none,
|
this.accountMenuItem = AccountMenuItem.none,
|
||||||
this.cc,
|
this.cc,
|
||||||
this.bcc,
|
this.bcc,
|
||||||
});
|
this.labelId,
|
||||||
|
}) : assert(
|
||||||
|
!(mailboxId != null && labelId != null),
|
||||||
|
'NavigationRouter accepts either mailboxId or labelId, not both.',
|
||||||
|
);
|
||||||
|
|
||||||
factory NavigationRouter.initial() => NavigationRouter();
|
factory NavigationRouter.initial() => NavigationRouter();
|
||||||
|
|
||||||
@@ -53,5 +59,6 @@ class NavigationRouter with EquatableMixin {
|
|||||||
accountMenuItem,
|
accountMenuItem,
|
||||||
cc,
|
cc,
|
||||||
bcc,
|
bcc,
|
||||||
|
labelId,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ abstract class RouteUtils {
|
|||||||
static const String paramID = 'id';
|
static const String paramID = 'id';
|
||||||
static const String paramType = 'type';
|
static const String paramType = 'type';
|
||||||
static const String paramContext = 'context';
|
static const String paramContext = 'context';
|
||||||
|
static const String paramLabelId = 'labelId';
|
||||||
static const String paramQuery = 'q';
|
static const String paramQuery = 'q';
|
||||||
static const String paramRouteName = 'routeName';
|
static const String paramRouteName = 'routeName';
|
||||||
static const String paramMailtoAddress = 'mailtoAddress';
|
static const String paramMailtoAddress = 'mailtoAddress';
|
||||||
@@ -60,7 +61,9 @@ abstract class RouteUtils {
|
|||||||
}
|
}
|
||||||
servicePath = servicePath.withQueryParameters([
|
servicePath = servicePath.withQueryParameters([
|
||||||
StringQueryParameter(paramType, router.dashboardType.name),
|
StringQueryParameter(paramType, router.dashboardType.name),
|
||||||
if (router.mailboxId != null)
|
if (router.labelId != null)
|
||||||
|
StringQueryParameter(paramLabelId, router.labelId!.value)
|
||||||
|
else if (router.mailboxId != null)
|
||||||
StringQueryParameter(paramContext, router.mailboxId!.id.value),
|
StringQueryParameter(paramContext, router.mailboxId!.id.value),
|
||||||
if (router.searchQuery != null)
|
if (router.searchQuery != null)
|
||||||
StringQueryParameter(paramQuery, router.searchQuery!.value),
|
StringQueryParameter(paramQuery, router.searchQuery!.value),
|
||||||
@@ -124,6 +127,7 @@ abstract class RouteUtils {
|
|||||||
final idParam = parameters[paramID];
|
final idParam = parameters[paramID];
|
||||||
final typeParam = parameters[paramType];
|
final typeParam = parameters[paramType];
|
||||||
final contextPram = parameters[paramContext];
|
final contextPram = parameters[paramContext];
|
||||||
|
final labelIdPram = parameters[paramLabelId];
|
||||||
final queryParam = parameters[paramQuery];
|
final queryParam = parameters[paramQuery];
|
||||||
final routeName = parameters[paramRouteName];
|
final routeName = parameters[paramRouteName];
|
||||||
final mailtoAddress = parameters[paramMailtoAddress];
|
final mailtoAddress = parameters[paramMailtoAddress];
|
||||||
@@ -133,7 +137,10 @@ abstract class RouteUtils {
|
|||||||
final body = parameters[paramBody];
|
final body = parameters[paramBody];
|
||||||
|
|
||||||
final emailId = idParam != null ? EmailId(Id(idParam)) : null;
|
final emailId = idParam != null ? EmailId(Id(idParam)) : null;
|
||||||
final mailboxId = contextPram != null ? MailboxId(Id(contextPram)) : null;
|
final labelId = labelIdPram != null ? Id(labelIdPram) : null;
|
||||||
|
final mailboxId = labelId == null && contextPram != null
|
||||||
|
? MailboxId(Id(contextPram))
|
||||||
|
: null;
|
||||||
final searchQuery = queryParam != null ? SearchQuery(queryParam) : null;
|
final searchQuery = queryParam != null ? SearchQuery(queryParam) : null;
|
||||||
final dashboardType = DashboardType.values.firstWhereOrNull((type) => type.name == typeParam) ?? DashboardType.normal;
|
final dashboardType = DashboardType.values.firstWhereOrNull((type) => type.name == typeParam) ?? DashboardType.normal;
|
||||||
final settingType = AccountMenuItem.values.firstWhereOrNull((type) => type.getAliasBrowser() == typeParam) ?? AccountMenuItem.none;
|
final settingType = AccountMenuItem.values.firstWhereOrNull((type) => type.getAliasBrowser() == typeParam) ?? AccountMenuItem.none;
|
||||||
@@ -147,6 +154,7 @@ abstract class RouteUtils {
|
|||||||
return NavigationRouter(
|
return NavigationRouter(
|
||||||
emailId: emailId,
|
emailId: emailId,
|
||||||
mailboxId: mailboxId,
|
mailboxId: mailboxId,
|
||||||
|
labelId: labelId,
|
||||||
searchQuery: searchQuery,
|
searchQuery: searchQuery,
|
||||||
dashboardType: dashboardType,
|
dashboardType: dashboardType,
|
||||||
routeName: routeName,
|
routeName: routeName,
|
||||||
|
|||||||
Reference in New Issue
Block a user