From 97b2f6ffe7fa09a2188163740865322582b00b59 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Tue, 13 Oct 2015 15:18:01 -0400 Subject: Made further changes based on feedback --- web/react/stores/preference_store.jsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'web/react/stores') diff --git a/web/react/stores/preference_store.jsx b/web/react/stores/preference_store.jsx index 4d7fb9ad6..d71efa10f 100644 --- a/web/react/stores/preference_store.jsx +++ b/web/react/stores/preference_store.jsx @@ -9,6 +9,14 @@ const UserStore = require('../stores/user_store.jsx'); const CHANGE_EVENT = 'change'; +function getPreferenceKey(category, name) { + return `${category}-${name}`; +} + +function getPreferenceKeyForModel(preference) { + return `${preference.category}-${preference.name}`; +} + class PreferenceStoreClass extends EventEmitter { constructor() { super(); @@ -28,20 +36,12 @@ class PreferenceStoreClass extends EventEmitter { this.dispatchToken = AppDispatcher.register(this.handleEventPayload); } - getKey(category, name) { - return `${category}-${name}`; - } - - getKeyForModel(preference) { - return `${preference.category}-${preference.name}`; - } - getAllPreferences() { return new Map(BrowserStore.getItem('preferences', [])); } getPreference(category, name, defaultValue = '') { - return this.getAllPreferences().get(this.getKey(category, name)) || defaultValue; + return this.getAllPreferences().get(getPreferenceKey(category, name)) || defaultValue; } getPreferences(category) { @@ -70,7 +70,7 @@ class PreferenceStoreClass extends EventEmitter { setPreference(category, name, value) { const preferences = this.getAllPreferences(); - const key = this.getKey(category, name); + const key = getPreferenceKey(category, name); let preference = preferences.get(key); if (!preference) { @@ -109,7 +109,7 @@ class PreferenceStoreClass extends EventEmitter { const preferences = this.getAllPreferences(); for (const preference of action.preferences) { - preferences.set(this.getKeyForModel(preference), preference); + preferences.set(getPreferenceKeyForModel(preference), preference); } this.setAllPreferences(preferences); -- cgit v1.2.3-1-g7c22