diff --git a/src/models/list.js b/src/models/list.js index 965c6f6d41e999d8222088ae13444f470b812af7..d047b8262cef95e1d16bd73e77f88ab3208ac98f 100644 --- a/src/models/list.js +++ b/src/models/list.js @@ -10,6 +10,21 @@ export default { effects: { *fetch({ payload }, { call, put }) { + yield put({ + type: 'changeLoading', + payload: true, + }); + const response = yield call(queryFakeList, payload); + yield put({ + type: 'queryList', + payload: Array.isArray(response) ? response : [], + }); + yield put({ + type: 'changeLoading', + payload: false, + }); + }, + *appendFetch({ payload }, { call, put }) { yield put({ type: 'changeLoading', payload: true, @@ -27,6 +42,12 @@ export default { }, reducers: { + queryList(state, action) { + return { + ...state, + list: action.payload, + }; + }, appendList(state, action) { return { ...state, diff --git a/src/routes/List/SearchList.js b/src/routes/List/SearchList.js index dadde8de86887f7b18031a8cbda4f3159b933481..910bbee04d04a0e1afd8c8c7ca8786bf35c1c6f3 100644 --- a/src/routes/List/SearchList.js +++ b/src/routes/List/SearchList.js @@ -32,7 +32,7 @@ export default class SearchList extends Component { fetchMore = () => { this.props.dispatch({ - type: 'list/fetch', + type: 'list/appendFetch', payload: { count: pageSize, },