Use isPrimed api for getUser fetch action
This commit is contained in:
@ -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
|
||||||
|
@ -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
|
||||||
|
Reference in New Issue
Block a user