TF-4274 Avoid clearing all caches on refresh for non‑web platforms
This commit is contained in:
@@ -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)
|
||||
@@ -506,7 +506,7 @@ abstract class BaseController extends GetxController
|
||||
if (_isFcmEnabled) {
|
||||
await _handleDeleteFCMRegistration();
|
||||
}
|
||||
clearAllData();
|
||||
await clearAllData();
|
||||
}
|
||||
|
||||
Future<void> _handleDeleteFCMRegistration() async {
|
||||
|
||||
@@ -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(
|
||||
|
||||
+8
-6
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user