1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00
onion/js/sources/whitelabel_source.js

33 lines
820 B
JavaScript

'use strict';
import request from '../utils/request';
import WhitelabelActions from '../actions/whitelabel_actions';
import { getCurrentSubdomain } from '../utils/url';
const WhitelabelSource = {
lookupWhitelabel: {
remote() {
return request('whitelabel_settings', {
urlTemplateSpec: {
subdomain: getCurrentSubdomain()
}
});
},
local(state) {
return Object.keys(state.whitelabel).length ? state : {};
},
success: WhitelabelActions.successFetchWhitelabel,
error: WhitelabelActions.errorWhitelabel,
shouldFetch(state, invalidateCache) {
return invalidateCache || !Object.keys(state.whitelabel).length;
}
}
};
export default WhitelabelSource;