1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-11-08 21:42:24 +03:00

fallback after receiving settings rather than {} because its truthy

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2018-01-17 18:17:26 +00:00
parent 43bb8c561d
commit b7204e79a7
3 changed files with 21 additions and 16 deletions

View File

@@ -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);
}