TF-4274 Avoid clearing all caches on refresh for non‑web platforms

This commit is contained in:
dab246
2026-01-28 16:42:53 +07:00
committed by Dat H. Pham
parent 4d77018027
commit 18d9a47431
6 changed files with 21 additions and 15 deletions
@@ -20,7 +20,7 @@ The issue typically manifests in the following sequence, as reported in [Issue #
* **Crucially:** The email *can* be found using the Search function (proving data existence). * **Crucially:** The email *can* be found using the Search function (proving data existence).
4. **Resolution:** The user is forced to **Logout and Login**, which magically restores the email to the list. 4. **Resolution:** The user is forced to **log out and log in**, which magically restores the email to the list.
### Root Cause Analysis ### Root Cause Analysis
@@ -104,4 +104,4 @@ FORCE_EMAIL_QUERY=false
## References ## References
* **Github Issue:** [linagora/tmail-flutter#4274](https://github.com/linagora/tmail-flutter/issues/4274) * **GitHub Issue:** [linagora/tmail-flutter#4274](https://github.com/linagora/tmail-flutter/issues/4274)
+1 -1
View File
@@ -506,7 +506,7 @@ abstract class BaseController extends GetxController
if (_isFcmEnabled) { if (_isFcmEnabled) {
await _handleDeleteFCMRegistration(); await _handleDeleteFCMRegistration();
} }
clearAllData(); await clearAllData();
} }
Future<void> _handleDeleteFCMRegistration() async { Future<void> _handleDeleteFCMRegistration() async {
+1 -1
View File
@@ -70,7 +70,7 @@ class CachingManager {
await Future.wait([ await Future.wait([
clearMailDataCached(), clearMailDataCached(),
clearAccountDataCached(), clearAccountDataCached(),
], eagerError: true); ]);
} catch (e) { } catch (e) {
logWarning('CachingManager::clearAll: Cannot clear all cache: $e'); logWarning('CachingManager::clearAll: Cannot clear all cache: $e');
} }
@@ -254,7 +254,11 @@ class LoginController extends ReloadableController {
SmartDialog.dismiss(); SmartDialog.dismiss();
if (PlatformInfo.isWeb) { if (PlatformInfo.isWeb) {
await cachingManager.clearAllEmailAndStateCache(); try {
await cachingManager.clearAllEmailAndStateCache();
} catch (e) {
logWarning('$runtimeType::handleReloaded: Failed to clear cache: $e');
}
} }
popAndPush( popAndPush(
@@ -611,14 +611,16 @@ class MailboxDashBoardController extends ReloadableController
@override @override
Future<void> onBeforeUnloadBrowserListener(html.Event event) async { Future<void> onBeforeUnloadBrowserListener(html.Event event) async {
log('MailboxDashBoardController::onBeforeUnloadBrowserListener:event = ${event.runtimeType} | hasComposer = ${twakeAppManager.hasComposer} | isExecutingBeforeReconnect = ${twakeAppManager.isExecutingBeforeReconnect}'); log('MailboxDashBoardController::onBeforeUnloadBrowserListener:event = ${event.runtimeType} | hasComposer = ${twakeAppManager.hasComposer} | isExecutingBeforeReconnect = ${twakeAppManager.isExecutingBeforeReconnect}');
if (PlatformInfo.isWeb) { final shouldPrevent = event is html.BeforeUnloadEvent &&
await cachingManager.clearAllEmailAndStateCache(); twakeAppManager.hasComposer &&
!twakeAppManager.isExecutingBeforeReconnect;
if (shouldPrevent) {
event.preventDefault();
} }
if (event is html.BeforeUnloadEvent && if (PlatformInfo.isWeb) {
twakeAppManager.hasComposer && await cachingManager.clearAllEmailAndStateCache();
!twakeAppManager.isExecutingBeforeReconnect) {
event.preventDefault();
} }
} }
@@ -355,7 +355,7 @@ class ThreadController extends BaseController with EmailActionController {
if (action is RefreshChangeEmailAction) { if (action is RefreshChangeEmailAction) {
_refreshEmailChanges(newState: action.newState); _refreshEmailChanges(newState: action.newState);
} else if (action is RefreshAllEmailAction) { } else if (action is RefreshAllEmailAction) {
refreshAllEmail(forceEmailQuery: true); refreshAllEmail(shouldClearCache: PlatformInfo.isWeb);
mailboxDashBoardController.clearEmailUIAction(); mailboxDashBoardController.clearEmailUIAction();
} }
}); });
@@ -604,8 +604,8 @@ class ThreadController extends BaseController with EmailActionController {
} }
} }
Future<void> refreshAllEmail({bool forceEmailQuery = false}) async { Future<void> refreshAllEmail({bool shouldClearCache = false}) async {
if (forceEmailQuery) { if (shouldClearCache) {
await cachingManager.clearAllEmailAndStateCache(); await cachingManager.clearAllEmailAndStateCache();
} }
@@ -622,7 +622,7 @@ class ThreadController extends BaseController with EmailActionController {
if (searchController.isSearchEmailRunning) { if (searchController.isSearchEmailRunning) {
_searchEmail(limit: limitEmailFetched); _searchEmail(limit: limitEmailFetched);
} else { } else {
getAllEmailAction(forceEmailQuery: forceEmailQuery); getAllEmailAction();
} }
} }