2015-06-29 15:58:47 +02:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-07 09:31:38 +02:00
|
|
|
import { altWhitelabel } from '../alt';
|
2016-02-05 10:38:59 +01:00
|
|
|
|
2015-06-29 15:58:47 +02:00
|
|
|
import WhitelabelActions from '../actions/whitelabel_actions';
|
2016-02-05 10:38:59 +01:00
|
|
|
|
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 = {
|
|
|
|
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) {
|
2016-02-05 10:38:59 +01:00
|
|
|
if (invalidateCache || !this.getInstance().isLoading()) {
|
|
|
|
this.getInstance().lookupWhitelabel(invalidateCache);
|
2015-11-03 10:07:44 +01:00
|
|
|
}
|
2016-02-05 10:38:59 +01:00
|
|
|
|
|
|
|
// Prevent alt from sending an empty change event when a request is sent
|
|
|
|
// off to the source
|
|
|
|
this.preventDefault();
|
2015-06-29 15:58:47 +02:00
|
|
|
}
|
|
|
|
|
2015-12-10 15:41:55 +01:00
|
|
|
onSuccessFetchWhitelabel({ whitelabel = {} }) {
|
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');
|