initialize only once when using removeRecursive

This commit is contained in:
marlon-erler
2024-07-20 04:39:03 +02:00
parent d996fb031e
commit a634aa7768
+5 -2
View File
@@ -28,7 +28,7 @@ export default class StorageModel {
const key: string = StorageModel.pathComponentsToKey(...pathComponents); const key: string = StorageModel.pathComponentsToKey(...pathComponents);
localStorage.removeItem(key); localStorage.removeItem(key);
if (shouldInitialize) { if (shouldInitialize == true) {
this.initializeTree(); this.initializeTree();
} }
}; };
@@ -46,8 +46,9 @@ export default class StorageModel {
continue a; continue a;
} }
this.remove(pathComponentsOfCurrentEntity); this.remove(pathComponentsOfCurrentEntity, false);
} }
this.initializeTree();
}; };
list = (pathComponents: string[]): string[] => { list = (pathComponents: string[]): string[] => {
@@ -81,6 +82,8 @@ export default class StorageModel {
// utility // utility
initializeTree = (): void => { initializeTree = (): void => {
console.log("initializing tree")
this.storageEntryTree = {}; this.storageEntryTree = {};
for (const key of Object.keys(localStorage)) { for (const key of Object.keys(localStorage)) {
const components: string[] = StorageModel.keyToPathComponents(key); const components: string[] = StorageModel.keyToPathComponents(key);