Files
freeCodeCamp/common/app/flux/Actions.js
2016-01-04 14:27:22 -08:00

46 lines
923 B
JavaScript

import { Actions } from 'thundercats';
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' };
},
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);
});
},
updateRoute(route) {
return { route };
},
goBack: null
});