From 39c122fe4f09d048b5237dd539c66b09855cad76 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 21 Jan 2017 22:27:55 +0100 Subject: [PATCH] fix local storage idiocy --- src/UserSettingsStore.js | 5 +++-- src/components/structures/UserSettings.js | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/UserSettingsStore.js b/src/UserSettingsStore.js index f2f99603d6..d7d3e7bc7a 100644 --- a/src/UserSettingsStore.js +++ b/src/UserSettingsStore.js @@ -150,7 +150,8 @@ module.exports = { }, getLocalSettings: function() { - return localStorage.getItem('mx_local_settings'); + var localSettingsString = localStorage.getItem('mx_local_settings') || '{}'; + return JSON.parse(localSettingsString); }, getLocalSetting: function(type, defaultValue = null) { @@ -162,7 +163,7 @@ module.exports = { var settings = this.getLocalSettings(); settings[type] = value; // FIXME: handle errors - localStorage.setItem('mx_local_settings', settings); + localStorage.setItem('mx_local_settings', JSON.stringify(settings)); }, isFeatureEnabled: function(feature: string): boolean { diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index a262431f2b..1dd30b679c 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -485,7 +485,9 @@ module.exports = React.createClass({
  • {identityKey}
  • - { CRYPTO_SETTINGS_LABELS.map( this._renderLocalSetting ) } +
    + { CRYPTO_SETTINGS_LABELS.map( this._renderLocalSetting ) } +
    ); },