Skip to content

Commit

Permalink
Clear settings caches on reset rather than custom lifecycle method (#…
Browse files Browse the repository at this point in the history
…12859)

* Clear settings caches on reset

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Derp

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Delint

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy authored Aug 5, 2024
1 parent 0905864 commit 54e5321
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions src/Lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import { setSentryUser } from "./sentry";
import SdkConfig from "./SdkConfig";
import { DialogOpener } from "./utils/DialogOpener";
import { Action } from "./dispatcher/actions";
import AbstractLocalStorageSettingsHandler from "./settings/handlers/AbstractLocalStorageSettingsHandler";
import { OverwriteLoginPayload } from "./dispatcher/payloads/OverwriteLoginPayload";
import { SdkContextClass } from "./contexts/SDKContext";
import { messageForLoginError } from "./utils/ErrorUtils";
Expand Down Expand Up @@ -1087,7 +1086,6 @@ async function clearStorage(opts?: { deleteEverything?: boolean }): Promise<void
const registrationTime = window.localStorage.getItem("mx_registration_time");

window.localStorage.clear();
AbstractLocalStorageSettingsHandler.clear();

try {
await StorageAccess.idbDelete("account", ACCESS_TOKEN_STORAGE_KEY);
Expand Down
7 changes: 5 additions & 2 deletions src/settings/handlers/AbstractLocalStorageSettingsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export default abstract class AbstractLocalStorageSettingsHandler extends Settin
}
};

// Expose the clear event for Lifecycle to call, the storage listener only fires for changes from other tabs
public static clear(): void {
private static clear(): void {
AbstractLocalStorageSettingsHandler.itemCache.clear();
AbstractLocalStorageSettingsHandler.objectCache.clear();
}
Expand Down Expand Up @@ -108,4 +107,8 @@ export default abstract class AbstractLocalStorageSettingsHandler extends Settin
public isSupported(): boolean {
return localStorage !== undefined && localStorage !== null;
}

public reset(): void {
AbstractLocalStorageSettingsHandler.clear();
}
}

0 comments on commit 54e5321

Please sign in to comment.