fix(cnb): use Email/query + Email/get when switch mailbox and reload the email list
(cherry picked from commit 9444d8d28acb3ad4997091162f7addb763d83234)
This commit is contained in:
@@ -74,6 +74,7 @@ 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';
|
||||
import 'package:tmail_ui_user/main/routes/route_utils.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||
import 'package:universal_html/html.dart' as html;
|
||||
|
||||
typedef StartRangeSelection = int;
|
||||
@@ -273,6 +274,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
resetToOriginalValue();
|
||||
getAllEmailAction(
|
||||
getLatestChanges: mailboxDashBoardController.isFirstSessionLoad,
|
||||
forceEmailQuery: forceEmailQuery,
|
||||
);
|
||||
mailboxDashBoardController.setIsFirstSessionLoad(false);
|
||||
} else if (mailbox == null) { // disable current mailbox when search active
|
||||
@@ -353,7 +355,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
if (action is RefreshChangeEmailAction) {
|
||||
_refreshEmailChanges(newState: action.newState);
|
||||
} else if (action is RefreshAllEmailAction) {
|
||||
refreshAllEmail();
|
||||
refreshAllEmail(forceEmailQuery: forceEmailQuery);
|
||||
mailboxDashBoardController.clearEmailUIAction();
|
||||
}
|
||||
});
|
||||
@@ -472,6 +474,9 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
handleLoadMoreEmailsRequest();
|
||||
}
|
||||
|
||||
bool get forceEmailQuery =>
|
||||
PlatformInfo.isWeb && AppConfig.isForceEmailQueryEnabled;
|
||||
|
||||
void _handleErrorGetAllOrRefreshChangesEmail(Object error, StackTrace stackTrace) async {
|
||||
logWarning('ThreadController::_handleErrorGetAllOrRefreshChangesEmail():Error: $error');
|
||||
if (error is CannotCalculateChangesMethodResponseException) {
|
||||
@@ -578,6 +583,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
|
||||
void getAllEmailAction({
|
||||
bool getLatestChanges = true,
|
||||
bool forceEmailQuery = false,
|
||||
}) {
|
||||
log('ThreadController::_getAllEmailAction:getLatestChanges = $getLatestChanges');
|
||||
if (_session != null &&_accountId != null) {
|
||||
@@ -594,13 +600,14 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
),
|
||||
getLatestChanges: getLatestChanges,
|
||||
useCache: selectedMailbox?.isCacheable ?? false,
|
||||
forceEmailQuery: forceEmailQuery,
|
||||
));
|
||||
} else {
|
||||
consumeState(Stream.value(Left(GetAllEmailFailure(NotFoundSessionException()))));
|
||||
}
|
||||
}
|
||||
|
||||
void refreshAllEmail() {
|
||||
void refreshAllEmail({bool forceEmailQuery = false}) {
|
||||
if (searchController.isSearchEmailRunning) {
|
||||
consumeState(Stream.value(Right(SearchingState())));
|
||||
} else {
|
||||
@@ -614,7 +621,7 @@ class ThreadController extends BaseController with EmailActionController {
|
||||
if (searchController.isSearchEmailRunning) {
|
||||
_searchEmail(limit: limitEmailFetched);
|
||||
} else {
|
||||
getAllEmailAction();
|
||||
getAllEmailAction(forceEmailQuery: forceEmailQuery);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user