Make structure changes to hikes
This commit is contained in:
@@ -4,46 +4,42 @@ import debugFactory from 'debug';
|
||||
const debug = debugFactory('freecc:app:actions');
|
||||
|
||||
export default Actions({
|
||||
shouldBindMethods: true,
|
||||
refs: { displayName: 'AppActions' },
|
||||
|
||||
setTitle(title = 'Learn To Code') {
|
||||
return { title: title + '| Free Code Camp' };
|
||||
return { title: title + ' | Free Code Camp' };
|
||||
},
|
||||
|
||||
setUser({
|
||||
username,
|
||||
picture,
|
||||
progressTimestamps = [],
|
||||
isFrontEndCert,
|
||||
isFullStackCert
|
||||
}) {
|
||||
return {
|
||||
username,
|
||||
picture,
|
||||
points: progressTimestamps.length,
|
||||
isFrontEndCert,
|
||||
isFullStackCert
|
||||
};
|
||||
getUser({ isPrimed }) {
|
||||
if (isPrimed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
debug('fetching user data');
|
||||
return this.readService$('user', null, null)
|
||||
.map(function({
|
||||
username,
|
||||
picture,
|
||||
progressTimestamps = [],
|
||||
isFrontEndCert,
|
||||
isFullStackCert
|
||||
}) {
|
||||
return {
|
||||
username,
|
||||
picture,
|
||||
points: progressTimestamps.length,
|
||||
isFrontEndCert,
|
||||
isFullStackCert
|
||||
};
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
},
|
||||
|
||||
getUser: null,
|
||||
updateRoute(route) {
|
||||
return { route };
|
||||
},
|
||||
goBack: null
|
||||
})
|
||||
.refs({ displayName: 'AppActions' })
|
||||
.init(({ instance: appActions, args: [services] }) => {
|
||||
appActions.getUser.subscribe(({ isPrimed }) => {
|
||||
if (isPrimed) {
|
||||
debug('isPrimed');
|
||||
return;
|
||||
}
|
||||
services.read('user', null, null, (err, user) => {
|
||||
if (err) {
|
||||
return debug('user service error');
|
||||
}
|
||||
debug('user service returned successful');
|
||||
return appActions.setUser(user);
|
||||
});
|
||||
});
|
||||
return appActions;
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user