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

43 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-06-29 15:58:47 +02:00
'use strict';
import { altWhitelabel } from '../alt';
2015-06-29 15:58:47 +02:00
import WhitelabelActions from '../actions/whitelabel_actions';
import WhitelabelSource from '../sources/whitelabel_source';
2015-06-29 15:58:47 +02:00
class WhitelabelStore {
constructor() {
this.whitelabel = {};
this.whitelabelMeta = {
err: null
};
2015-06-29 15:58:47 +02:00
this.bindActions(WhitelabelActions);
this.registerAsync(WhitelabelSource);
}
onFetchWhitelabel(invalidateCache) {
if (invalidateCache || !this.getInstance().isLoading()) {
this.getInstance().lookupWhitelabel(invalidateCache);
}
// 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
}
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;
}
onErrorCurrentUser(err) {
console.logGlobal(err);
this.whitelabelMeta.err = err;
}
2015-06-29 15:58:47 +02:00
}
export default altWhitelabel.createStore(WhitelabelStore, 'WhitelabelStore');