From c17685731a424d36412674bbf00d7a4b03574740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Wed, 4 Nov 2015 11:36:42 +0100 Subject: [PATCH] Fix invalidateCache functionality --- js/sources/user_source.js | 2 +- js/sources/whitelabel_source.js | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 js/sources/whitelabel_source.js diff --git a/js/sources/user_source.js b/js/sources/user_source.js index 05165391..5940169b 100644 --- a/js/sources/user_source.js +++ b/js/sources/user_source.js @@ -18,7 +18,7 @@ const UserSource = { success: UserActions.successFetchCurrentUser, error: UserActions.currentUserFailed, shouldFetch(state) { - return state.invalidateCache || state.currentUser && !state.currentUser.email; + return state.userMeta.invalidateCache || state.currentUser && !state.currentUser.email; } }, diff --git a/js/sources/whitelabel_source.js b/js/sources/whitelabel_source.js new file mode 100644 index 00000000..eda0ba19 --- /dev/null +++ b/js/sources/whitelabel_source.js @@ -0,0 +1,25 @@ +'use strict'; + +import requests from '../utils/requests'; +import WhitelabelActions from '../actions/whitelabel_actions'; + +import { getSubdomain } from '../utils/general_utils'; + + +const WhitelabelSource = { + lookupWhitelabel: { + remote() { + return requests.get('whitelabel_settings', {'subdomain': getSubdomain()}); + }, + local(state) { + return Object.keys(state.whitelabel).length > 0 ? state : {}; + }, + success: WhitelabelActions.successFetchWhitelabel, + error: WhitelabelActions.whitelabelFailed, + shouldFetch(state) { + return state.whitelabelMeta.invalidateCache || Object.keys(state.whitelabel).length === 0; + } + } +}; + +export default WhitelabelSource; \ No newline at end of file