improve performance and memory utilization of clearAppData
This commit is contained in:
parent
d233220b39
commit
6ae3e2c1ae
1 changed files with 5 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
|||
import { showSnackbar } from './snackbarHelper';
|
||||
import { showSnackbar } from "./snackbarHelper";
|
||||
|
||||
const LOCAL_STORAGE_APP_CONTEXT = "ffc_";
|
||||
|
||||
|
@ -25,16 +25,12 @@ export function remove(key: string): void {
|
|||
}
|
||||
|
||||
function clearAppData(): void {
|
||||
const keysToDelete = [];
|
||||
for (let i = 0; i < localStorage.length; i++) {
|
||||
const key = localStorage.key(i) || "";
|
||||
if (key.startsWith(LOCAL_STORAGE_APP_CONTEXT)) {
|
||||
keysToDelete.push(key);
|
||||
for (let i = localStorage.length - 1; i >= 0; i--) {
|
||||
const key = localStorage.key(i);
|
||||
if (key && key.startsWith(LOCAL_STORAGE_APP_CONTEXT)) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
for (const key of keysToDelete) {
|
||||
localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
export function readFromLocalStorage(context: Context) {
|
||||
|
|
Loading…
Reference in a new issue