[web] fix utils/list

This commit is contained in:
Jason 2016-06-23 01:23:16 +08:00
parent 2358d79ac5
commit 3c4e81aeff
3 changed files with 30 additions and 27 deletions

View File

@ -103,7 +103,7 @@ export function handleWsMsg(msg) {
}
/**
* @private
* @public websocket
*/
export function fetchData() {
return dispatch => {

View File

@ -122,30 +122,6 @@ export function selectFlow(id) {
}
}
/**
* @public websocket
*/
export function handleWsMsg(msg) {
if (msg.cmd === WS_CMD_RESET) {
return fetchData()
}
return { type: WS_MSG, msg }
}
/**
* @public websocket
*/
export function fetchData() {
return dispatch => {
dispatch(request())
return fetch('/flows')
.then(res => res.json())
.then(json => dispatch(receive(json.data)))
.catch(error => dispatch(fetchError(error)))
}
}
/**
* @public
*/
@ -228,6 +204,32 @@ export function upload(file) {
return { type: REQUEST_ACTION }
}
/**
* This action creater takes all WebSocket events
*
* @public websocket
*/
export function handleWsMsg(msg) {
if (msg.cmd === WS_CMD_RESET) {
return fetchData()
}
return { type: WS_MSG, msg }
}
/**
* @public websocket
*/
export function fetchData() {
return dispatch => {
dispatch(request())
return fetch('/flows')
.then(res => res.json())
.then(json => dispatch(receive(json.data)))
.catch(error => dispatch(fetchError(error)))
}
}
/**
* @private
*/

View File

@ -87,13 +87,14 @@ export default function reduce(state = defaultState, action) {
}
case RECEIVE:
return {
return state[SYM_PENDING].reduce(reduce, {
...state,
[SYM_PENDING]: [],
isFetching: false,
raw: action.list,
data: action.list.filter(state[SYM_FILTER]).sort(state[SYM_SORTER]),
byId: _.fromPairs(action.list.map(item => [item.id, item])),
}
})
default:
return state