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

Commit

Permalink
Handle StorageEvent clear properly
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Apr 20, 2022
1 parent 71b0f6f commit 904f371
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/settings/handlers/AbstractLocalStorageSettingsHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,13 @@ export default abstract class AbstractLocalStorageSettingsHandler extends Settin

// Listen for storage changes from other tabs to bust the cache
window.addEventListener("storage", (e: StorageEvent) => {
this.itemCache.delete(e.key);
this.objectCache.delete(e.key);
if (e.key === null) {
this.itemCache.clear();
this.objectCache.clear();
} else {
this.itemCache.delete(e.key);
this.objectCache.delete(e.key);
}
});
}

Expand Down

0 comments on commit 904f371

Please sign in to comment.