Make structure changes to hikes

This commit is contained in:
Berkeley Martinez
2015-12-22 19:33:25 -08:00
parent 65b6715f68
commit 22cb610279
11 changed files with 154 additions and 116 deletions

View File

@@ -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;
});
});