Use isPrimed api for getUser fetch action

pull/5871/head
Berkeley Martinez 2016-01-05 12:26:14 -08:00
parent 8e1f8d2159
commit 53810102dd
2 changed files with 6 additions and 8 deletions

View File

@ -8,6 +8,9 @@ export default contain(
{
store: 'appStore',
fetchAction: 'appActions.getUser',
isPrimed({ username }) {
return !!username;
},
getPayload(props) {
return {
isPrimed: !!props.username

View File

@ -1,4 +1,5 @@
import { Actions } from 'thundercats';
import { Observable } from 'rx';
export default Actions({
@ -9,11 +10,7 @@ export default Actions({
return { title: title + ' | Free Code Camp' };
},
getUser({ isPrimed }) {
if (isPrimed) {
return null;
}
getUser() {
return this.readService$('user', null, null)
.map(({
username,
@ -30,9 +27,7 @@ export default Actions({
isFullStackCert
};
})
.catch(err => {
console.error(err);
});
.catch(err => Observable.just({ err }));
},
// routing