2015-06-29 15:58:47 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-07 09:31:38 +02:00
|
|
|
import { altWhitelabel } from '../alt';
|
2015-06-29 15:58:47 +02:00
|
|
|
import WhitelabelActions from '../actions/whitelabel_actions';
|
2015-11-03 10:07:44 +01:00
|
|
|
import WhitelabelSource from '../sources/whitelabel_source';
|
2015-06-29 15:58:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
class WhitelabelStore {
|
|
|
|
constructor() {
|
|
|
|
this.whitelabel = {};
|
2015-11-03 10:07:44 +01:00
|
|
|
this.whitelabelMeta = {
|
|
|
|
invalidateCache: false,
|
|
|
|
err: null
|
|
|
|
};
|
|
|
|
|
2015-06-29 15:58:47 +02:00
|
|
|
this.bindActions(WhitelabelActions);
|
2015-11-03 10:07:44 +01:00
|
|
|
this.registerAsync(WhitelabelSource);
|
|
|
|
}
|
|
|
|
|
|
|
|
onFetchWhitelabel(invalidateCache) {
|
|
|
|
this.whitelabelMeta.invalidateCache = invalidateCache;
|
|
|
|
|
|
|
|
if(!this.getInstance().isLoading()) {
|
|
|
|
this.getInstance().lookupWhitelabel();
|
|
|
|
}
|
2015-06-29 15:58:47 +02:00
|
|
|
}
|
|
|
|
|
2015-11-03 10:09:44 +01:00
|
|
|
onSuccessFetchWhitelabel({ whitelabel }) {
|
2015-11-03 10:07:44 +01:00
|
|
|
this.whitelabelMeta.invalidateCache = false;
|
2015-11-16 17:44:56 +01:00
|
|
|
this.whitelabelMeta.err = null;
|
2015-06-29 15:58:47 +02:00
|
|
|
this.whitelabel = whitelabel;
|
|
|
|
}
|
2015-11-03 10:07:44 +01:00
|
|
|
|
2015-11-16 17:16:13 +01:00
|
|
|
onErrorCurrentUser(err) {
|
2015-11-03 10:07:44 +01:00
|
|
|
console.logGlobal(err);
|
|
|
|
this.whitelabelMeta.err = err;
|
|
|
|
}
|
2015-06-29 15:58:47 +02:00
|
|
|
}
|
|
|
|
|
2015-10-07 09:31:38 +02:00
|
|
|
export default altWhitelabel.createStore(WhitelabelStore, 'WhitelabelStore');
|