Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 54e5321

Browse files
authored
Clear settings caches on reset rather than custom lifecycle method (#12859)
* Clear settings caches on reset Signed-off-by: Michael Telatynski <[email protected]> * Derp Signed-off-by: Michael Telatynski <[email protected]> * Delint Signed-off-by: Michael Telatynski <[email protected]> --------- Signed-off-by: Michael Telatynski <[email protected]>
1 parent 0905864 commit 54e5321

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Lifecycle.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import { setSentryUser } from "./sentry";
5858
import SdkConfig from "./SdkConfig";
5959
import { DialogOpener } from "./utils/DialogOpener";
6060
import { Action } from "./dispatcher/actions";
61-
import AbstractLocalStorageSettingsHandler from "./settings/handlers/AbstractLocalStorageSettingsHandler";
6261
import { OverwriteLoginPayload } from "./dispatcher/payloads/OverwriteLoginPayload";
6362
import { SdkContextClass } from "./contexts/SDKContext";
6463
import { messageForLoginError } from "./utils/ErrorUtils";
@@ -1087,7 +1086,6 @@ async function clearStorage(opts?: { deleteEverything?: boolean }): Promise<void
10871086
const registrationTime = window.localStorage.getItem("mx_registration_time");
10881087

10891088
window.localStorage.clear();
1090-
AbstractLocalStorageSettingsHandler.clear();
10911089

10921090
try {
10931091
await StorageAccess.idbDelete("account", ACCESS_TOKEN_STORAGE_KEY);

src/settings/handlers/AbstractLocalStorageSettingsHandler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export default abstract class AbstractLocalStorageSettingsHandler extends Settin
3535
}
3636
};
3737

38-
// Expose the clear event for Lifecycle to call, the storage listener only fires for changes from other tabs
39-
public static clear(): void {
38+
private static clear(): void {
4039
AbstractLocalStorageSettingsHandler.itemCache.clear();
4140
AbstractLocalStorageSettingsHandler.objectCache.clear();
4241
}
@@ -108,4 +107,8 @@ export default abstract class AbstractLocalStorageSettingsHandler extends Settin
108107
public isSupported(): boolean {
109108
return localStorage !== undefined && localStorage !== null;
110109
}
110+
111+
public reset(): void {
112+
AbstractLocalStorageSettingsHandler.clear();
113+
}
111114
}

0 commit comments

Comments
 (0)