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

49 lines
904 B
JavaScript
Raw Normal View History

import { Actions } from 'thundercats';
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;
}
return this.readService$('user', null, null)
.map(({
2015-12-22 19:33:25 -08:00
username,
picture,
progressTimestamps = [],
isFrontEndCert,
isFullStackCert
}) => {
2015-12-22 19:33:25 -08:00
return {
username,
picture,
points: progressTimestamps.length,
isFrontEndCert,
isFullStackCert
};
})
.catch(err => {
console.error(err);
});
},
2015-12-31 17:39:29 -08:00
// routing
goTo: null,
goBack: null,
updateLocation(location) {
return {
transform(state) {
return { ...state, location };
}
};
}
2015-12-22 19:33:25 -08:00
});