Files
freeCodeCamp/common/app/flux/Actions.js

46 lines
923 B
JavaScript
Raw Normal View History

import { Actions } from 'thundercats';
import debugFactory from 'debug';
const debug = debugFactory('freecc:app:actions');
export default Actions({
2015-12-22 19:33:25 -08:00
shouldBindMethods: true,
refs: { displayName: 'AppActions' },
setTitle(title = 'Learn To Code') {
2015-12-22 19:33:25 -08:00
return { title: title + ' | Free Code Camp' };
},
2015-12-22 19:33:25 -08:00
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) {
2015-10-27 20:07:28 -07:00
return { route };
},
goBack: null
2015-12-22 19:33:25 -08:00
});