mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
43 lines
1.1 KiB
JavaScript
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');
|