Use isPrimed api for getUser fetch action
This commit is contained in:
@ -8,6 +8,9 @@ export default contain(
|
||||
{
|
||||
store: 'appStore',
|
||||
fetchAction: 'appActions.getUser',
|
||||
isPrimed({ username }) {
|
||||
return !!username;
|
||||
},
|
||||
getPayload(props) {
|
||||
return {
|
||||
isPrimed: !!props.username
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user