From 9674f79f4016cf4600f9ba8577818284e64f9783 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 19 Mar 2020 14:05:47 -0700 Subject: [PATCH] Fixed: Removed items in queue still showing until refresh Closes #1378 (cherry picked from commit 479baf06a72b46429a80e19208fdc753ce0ed8ba) --- .../Store/Actions/Creators/createHandleActions.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/src/Store/Actions/Creators/createHandleActions.js b/frontend/src/Store/Actions/Creators/createHandleActions.js index 242294eeb..dc7b9cbd6 100644 --- a/frontend/src/Store/Actions/Creators/createHandleActions.js +++ b/frontend/src/Store/Actions/Creators/createHandleActions.js @@ -73,10 +73,6 @@ export default function createHandleActions(handlers, defaultState, section) { const newState = getSectionState(state, payloadSection); const items = newState.items; - if (!newState.itemMap) { - newState.itemMap = createItemMap(payload.data); - } - const index = payload.id in newState.itemMap ? newState.itemMap[payload.id] : -1; newState.items = [...items]; @@ -94,8 +90,10 @@ export default function createHandleActions(handlers, defaultState, section) { newState.items.splice(index, 1, newItem); } else if (!updateOnly) { - newState.items.push({ ...otherProps }); - newState.itemMap = createItemMap(newState.items); + const newIndex = newState.items.push({ ...otherProps }) - 1; + + newState.itemMap = { ...newState.itemMap }; + newState.itemMap[payload.id] = newIndex; } return updateSectionState(state, payloadSection, newState); @@ -151,7 +149,8 @@ export default function createHandleActions(handlers, defaultState, section) { const serverState = _.omit(data, ['records']); const calculatedState = { totalPages: Math.max(Math.ceil(data.totalRecords / data.pageSize), 1), - items: data.records + items: data.records, + itemMap: createItemMap(data.records) }; return updateSectionState(state, payloadSection, Object.assign(newState, serverState, calculatedState));