1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00
onion/js/sources/user_source.js

25 lines
536 B
JavaScript
Raw Normal View History

'use strict';
import requests from '../utils/requests';
import UserActions from '../actions/user_actions';
const UserSource = {
fetchUser: {
remote() {
return requests.get('user');
},
local(state) {
return state.currentUser && state.currentUser.email ? state.currentUser : {};
},
success: UserActions.receiveCurrentUser,
shouldFetch(state) {
return state.currentUser && !state.currentUser.email;
}
}
};
export default UserSource;