diff options
author | Harrison Healey <harrisonmhealey@gmail.com> | 2016-07-14 10:08:36 -0400 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-07-14 10:08:36 -0400 |
commit | caabfbcdd56bdced7c5c1d38e00f488adffe7c60 (patch) | |
tree | 4d52326767246f331da352f0427e34bf714e3130 /webapp/stores | |
parent | 8e810bc2ebb743717b5b0fc4541fcd3b2565966c (diff) | |
download | chat-caabfbcdd56bdced7c5c1d38e00f488adffe7c60.tar.gz chat-caabfbcdd56bdced7c5c1d38e00f488adffe7c60.tar.bz2 chat-caabfbcdd56bdced7c5c1d38e00f488adffe7c60.zip |
PLT-2992 Added the ability to use different themes for each team (#3411)
* Cleaned up user_settings_theme.jsx and import_theme_modal.jsx
* Made ImportThemeModal use a callback to return the theme to the user settings modal instead of saving it directly
* Moved user theme from model to preferences
* Added serverside API to delete preferences TODO update package with client stuff
* Changed constants.jsx so that Preferences and ActionTypes can be imported on their own
* Updated ThemeProps migration code to properly rename solarized code themes
* Fixed warnings thrown by AppDispatcher
* Added clientside UI to support team-specific themes
* Removed debugging code from test
* Fixed setting a user's theme when they haven't set their theme before
Diffstat (limited to 'webapp/stores')
-rw-r--r-- | webapp/stores/preference_store.jsx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/webapp/stores/preference_store.jsx b/webapp/stores/preference_store.jsx index 324ec4864..654036ae8 100644 --- a/webapp/stores/preference_store.jsx +++ b/webapp/stores/preference_store.jsx @@ -54,6 +54,16 @@ class PreferenceStoreClass extends EventEmitter { return parseInt(this.preferences.get(key), 10); } + getObject(category, name, defaultValue = null) { + const key = this.getKey(category, name); + + if (!this.preferences.has(key)) { + return defaultValue; + } + + return JSON.parse(this.preferences.get(key)); + } + getCategory(category) { const prefix = category + '--'; @@ -78,6 +88,10 @@ class PreferenceStoreClass extends EventEmitter { } } + deletePreference(preference) { + this.preferences.delete(this.getKey(preference.category, preference.name)); + } + clear() { this.preferences.clear(); } @@ -94,6 +108,18 @@ class PreferenceStoreClass extends EventEmitter { this.removeListener(CHANGE_EVENT, callback); } + getTheme(teamId) { + if (this.preferences.has(this.getKey(Constants.Preferences.CATEGORY_THEME, teamId))) { + return this.getObject(Constants.Preferences.CATEGORY_THEME, teamId); + } + + if (this.preferences.has(this.getKey(Constants.Preferences.CATEGORY_THEME, ''))) { + return this.getObject(Constants.Preferences.CATEGORY_THEME, ''); + } + + return Constants.THEMES.default; + } + handleEventPayload(payload) { const action = payload.action; @@ -108,6 +134,12 @@ class PreferenceStoreClass extends EventEmitter { this.setPreferencesFromServer(action.preferences); this.emitChange(); break; + case ActionTypes.DELETED_PREFERENCES: + for (const preference of action.preferences) { + this.deletePreference(preference); + } + this.emitChange(); + break; } } } |