fallback after receiving settings rather than {} because its truthy
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
43bb8c561d
commit
b7204e79a7
3 changed files with 21 additions and 16 deletions
|
@ -53,7 +53,8 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
return null; // wrong type or otherwise not set
|
||||
}
|
||||
|
||||
return this._getSettings()[settingName];
|
||||
const settings = this._getSettings() || {};
|
||||
return settings[settingName];
|
||||
}
|
||||
|
||||
setValue(settingName, roomId, newValue) {
|
||||
|
@ -74,7 +75,7 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const settings = this._getSettings();
|
||||
const settings = this._getSettings() || {};
|
||||
settings[settingName] = newValue;
|
||||
localStorage.setItem("mx_local_settings", JSON.stringify(settings));
|
||||
|
||||
|
@ -91,7 +92,7 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
|
||||
_getSettings() {
|
||||
const value = localStorage.getItem("mx_local_settings");
|
||||
if (!value) return {};
|
||||
if (!value) return null;
|
||||
return JSON.parse(value);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue