Use isPrimed api for getUser fetch action

This commit is contained in:
Berkeley Martinez
2016-01-05 12:26:14 -08:00
parent fc4af39210
commit 0166f7da15
2 changed files with 6 additions and 8 deletions

View File

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

View File

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