1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-24 10:16:29 +02:00
onion/js/stores/whitelabel_store.js

43 lines
1.1 KiB
JavaScript

'use strict';
import { altWhitelabel } from '../alt';
import WhitelabelActions from '../actions/whitelabel_actions';
import WhitelabelSource from '../sources/whitelabel_source';
class WhitelabelStore {
constructor() {
this.whitelabel = {};
this.whitelabelMeta = {
err: null
};
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();
}
onSuccessFetchWhitelabel({ whitelabel = {} }) {
this.whitelabelMeta.err = null;
this.whitelabel = whitelabel;
}
onErrorCurrentUser(err) {
console.logGlobal(err);
this.whitelabelMeta.err = err;
}
}
export default altWhitelabel.createStore(WhitelabelStore, 'WhitelabelStore');