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

Cache localStorage objects for SettingsStore #8366

Merged
merged 8 commits into from
Apr 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
consolidate
  • Loading branch information
t3chguy committed Apr 19, 2022
commit d9fef9519978fe8e061916e7aae1ccd11e45ffc3
Original file line number Diff line number Diff line change
@@ -69,13 +69,10 @@ export default abstract class AbstractLocalStorageSettingsHandler extends Settin
localStorage.setItem(key, JSON.stringify(value));
}

// handles both items and objects
protected removeItem(key: string): void {
localStorage.removeItem(key);
this.itemCache.delete(key);
}

protected removeObject(key: string): void {
localStorage.removeItem(key);
this.objectCache.delete(key);
}

2 changes: 1 addition & 1 deletion src/settings/handlers/RoomDeviceSettingsHandler.ts
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ export default class RoomDeviceSettingsHandler extends AbstractLocalStorageSetti
}

if (newValue === null) {
this.removeObject(this.getKey(settingName, roomId));
this.removeItem(this.getKey(settingName, roomId));
} else {
this.setObject(this.getKey(settingName, roomId), { value: newValue });
}