Update localstorage key prefixes

pull/384/merge
Tim Turner 8 years ago
parent 266f28883a
commit f38430d632

@ -2,7 +2,7 @@ var $ = require('jquery');
var vent = require('./vent');
module.exports = {
ConfigNamespace : 'Radarr',
ConfigNamespace : 'Radarr.',
Events : {
ConfigUpdatedEvent : 'ConfigUpdatedEvent'
@ -18,10 +18,10 @@ module.exports = {
},
getValueJson : function (key, defaultValue) {
key = this.ConfigNamespace + key;
var storeKey = this.ConfigNamespace + key;
defaultValue = defaultValue || {};
var storeValue = window.localStorage.getItem(key);
var storeValue = window.localStorage.getItem(storeKey);
if (!storeValue) {
return defaultValue;
@ -37,8 +37,8 @@ module.exports = {
},
getValue : function(key, defaultValue) {
key = this.ConfigNamespace + key;
var storeValue = window.localStorage.getItem(key);
var storeKey = this.ConfigNamespace + key;
var storeValue = window.localStorage.getItem(storeKey);
if (!storeValue) {
return defaultValue;
@ -52,22 +52,22 @@ module.exports = {
},
setValue : function(key, value) {
key = this.ConfigNamespace + key;
console.log('Config: [{0}] => [{1}]'.format(key, value));
var storeKey = this.ConfigNamespace + key;
console.log('Config: [{0}] => [{1}]'.format(storeKey, value));
if (this.getValue(key) === value.toString()) {
if (this.getValue(storeKey) === value.toString()) {
return;
}
try {
window.localStorage.setItem(key, value);
window.localStorage.setItem(storeKey, value);
vent.trigger(this.Events.ConfigUpdatedEvent, {
key : key,
value : value
});
}
catch (error) {
console.error('Unable to save config: [{0}] => [{1}]'.format(key, value));
console.error('Unable to save config: [{0}] => [{1}]'.format(storeKey, value));
}
}
};

Loading…
Cancel
Save