mirror of
https://github.com/ascribe/onion.git
synced 2025-01-18 16:57:00 +01:00
37 lines
794 B
JavaScript
37 lines
794 B
JavaScript
'use strict';
|
|
|
|
import { altUser } from '../alt';
|
|
import UserActions from '../actions/user_actions';
|
|
|
|
import UserSource from '../sources/user_source';
|
|
|
|
|
|
class UserStore {
|
|
constructor() {
|
|
this.currentUser = {};
|
|
this.invalidateCache = false;
|
|
|
|
this.bindActions(UserActions);
|
|
this.registerAsync(UserSource);
|
|
}
|
|
|
|
onFetchCurrentUser(invalidateCache) {
|
|
this.invalidateCache = invalidateCache;
|
|
|
|
if(!this.getInstance().isLoading()) {
|
|
this.getInstance().fetchUser();
|
|
}
|
|
}
|
|
|
|
onReceiveCurrentUser({users: [user]}) {
|
|
this.invalidateCache = false;
|
|
this.currentUser = user;
|
|
}
|
|
|
|
onDeleteCurrentUser() {
|
|
this.currentUser = {};
|
|
}
|
|
}
|
|
|
|
export default altUser.createStore(UserStore, 'UserStore');
|