initialize only once when using removeRecursive
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user