1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-31 17:17:48 +01:00
onion/js/sources/whitelabel_source.js

33 lines
820 B
JavaScript
Raw Normal View History

2015-11-04 11:36:42 +01:00
'use strict';
import request from '../utils/request';
2015-11-04 11:36:42 +01:00
import WhitelabelActions from '../actions/whitelabel_actions';
2016-06-13 17:33:47 +02:00
import { getCurrentSubdomain } from '../utils/url';
2015-11-04 11:36:42 +01:00
const WhitelabelSource = {
lookupWhitelabel: {
remote() {
return request('whitelabel_settings', {
urlTemplateSpec: {
subdomain: getCurrentSubdomain()
}
});
2015-11-04 11:36:42 +01:00
},
2015-11-04 11:36:42 +01:00
local(state) {
return Object.keys(state.whitelabel).length ? state : {};
2015-11-04 11:36:42 +01:00
},
2015-11-04 11:36:42 +01:00
success: WhitelabelActions.successFetchWhitelabel,
error: WhitelabelActions.errorWhitelabel,
shouldFetch(state, invalidateCache) {
return invalidateCache || !Object.keys(state.whitelabel).length;
2015-11-04 11:36:42 +01:00
}
}
};
export default WhitelabelSource;