From 84683e7abb07fd2d3a9e79b74cb9a1e4013ad83b Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 23 Jun 2016 23:48:17 +0800 Subject: [web] check item existence before update --- web/src/js/ducks/eventLog.js | 2 +- web/src/js/ducks/utils/view.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/src/js/ducks/eventLog.js b/web/src/js/ducks/eventLog.js index aa472592..81f19e2e 100644 --- a/web/src/js/ducks/eventLog.js +++ b/web/src/js/ducks/eventLog.js @@ -120,7 +120,7 @@ export function fetchData() { return fetchApi('/events') .then(res => res.json()) - .then(json => dispatch(receive(json.data))) + .then(json => dispatch(receive(json.data))) .catch(error => dispatch(fetchError(error))) } } diff --git a/web/src/js/ducks/utils/view.js b/web/src/js/ducks/utils/view.js index 20260537..87a05987 100755 --- a/web/src/js/ducks/utils/view.js +++ b/web/src/js/ducks/utils/view.js @@ -32,7 +32,7 @@ export default function reduce(state = defaultState, action) { } case ADD: - if (!action.filter(action.item)) { + if (state.indexOf[action.item.id] != null || !action.filter(action.item)) { return state } return { @@ -41,12 +41,18 @@ export default function reduce(state = defaultState, action) { } case REMOVE: + if (state.indexOf[action.item.id] == null) { + return state + } return { ...state, ...sortedRemove(state, action.id), } case UPDATE: + if (state.indexOf[action.item.id] == null) { + return + } const nextState = { ...state, ...sortedRemove(state, action.id), -- cgit v1.2.3