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).
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
@@ -104,4 +104,4 @@ FORCE_EMAIL_QUERY=false
## 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) {
await _handleDeleteFCMRegistration();
}
clearAllData();
await clearAllData();
}
Future<void> _handleDeleteFCMRegistration() async {
+1 -1
View File
@@ -70,7 +70,7 @@ class CachingManager {
await Future.wait([
clearMailDataCached(),
clearAccountDataCached(),
], eagerError: true);
]);
} catch (e) {
logWarning('CachingManager::clearAll: Cannot clear all cache: $e');
}
@@ -254,7 +254,11 @@ class LoginController extends ReloadableController {
SmartDialog.dismiss();
if (PlatformInfo.isWeb) {
await cachingManager.clearAllEmailAndStateCache();
try {
await cachingManager.clearAllEmailAndStateCache();
} catch (e) {
logWarning('$runtimeType::handleReloaded: Failed to clear cache: $e');
}
}
popAndPush(
@@ -611,14 +611,16 @@ class MailboxDashBoardController extends ReloadableController
@override
Future<void> onBeforeUnloadBrowserListener(html.Event event) async {
log('MailboxDashBoardController::onBeforeUnloadBrowserListener:event = ${event.runtimeType} | hasComposer = ${twakeAppManager.hasComposer} | isExecutingBeforeReconnect = ${twakeAppManager.isExecutingBeforeReconnect}');
if (PlatformInfo.isWeb) {
await cachingManager.clearAllEmailAndStateCache();
final shouldPrevent = event is html.BeforeUnloadEvent &&
twakeAppManager.hasComposer &&
!twakeAppManager.isExecutingBeforeReconnect;
if (shouldPrevent) {
event.preventDefault();
}
if (event is html.BeforeUnloadEvent &&
twakeAppManager.hasComposer &&
!twakeAppManager.isExecutingBeforeReconnect) {
event.preventDefault();
if (PlatformInfo.isWeb) {
await cachingManager.clearAllEmailAndStateCache();
}
}
@@ -355,7 +355,7 @@ class ThreadController extends BaseController with EmailActionController {
if (action is RefreshChangeEmailAction) {
_refreshEmailChanges(newState: action.newState);
} else if (action is RefreshAllEmailAction) {
refreshAllEmail(forceEmailQuery: true);
refreshAllEmail(shouldClearCache: PlatformInfo.isWeb);
mailboxDashBoardController.clearEmailUIAction();
}
});
@@ -604,8 +604,8 @@ class ThreadController extends BaseController with EmailActionController {
}
}
Future<void> refreshAllEmail({bool forceEmailQuery = false}) async {
if (forceEmailQuery) {
Future<void> refreshAllEmail({bool shouldClearCache = false}) async {
if (shouldClearCache) {
await cachingManager.clearAllEmailAndStateCache();
}
@@ -622,7 +622,7 @@ class ThreadController extends BaseController with EmailActionController {
if (searchController.isSearchEmailRunning) {
_searchEmail(limit: limitEmailFetched);
} else {
getAllEmailAction(forceEmailQuery: forceEmailQuery);
getAllEmailAction();
}
}