diff --git a/frontend/src/Store/Actions/Creators/createHandleActions.js b/frontend/src/Store/Actions/Creators/createHandleActions.js index dc7b9cbd6..36a103da1 100644 --- a/frontend/src/Store/Actions/Creators/createHandleActions.js +++ b/frontend/src/Store/Actions/Creators/createHandleActions.js @@ -72,8 +72,9 @@ export default function createHandleActions(handlers, defaultState, section) { if (section === baseSection) { const newState = getSectionState(state, payloadSection); const items = newState.items; + const itemMap = newState.itemMap ?? {}; - const index = payload.id in newState.itemMap ? newState.itemMap[payload.id] : -1; + const index = payload.id in itemMap ? itemMap[payload.id] : -1; newState.items = [...items]; @@ -92,7 +93,7 @@ export default function createHandleActions(handlers, defaultState, section) { } else if (!updateOnly) { const newIndex = newState.items.push({ ...otherProps }) - 1; - newState.itemMap = { ...newState.itemMap }; + newState.itemMap = { ...itemMap }; newState.itemMap[payload.id] = newIndex; } diff --git a/frontend/src/Store/Actions/importSeriesActions.js b/frontend/src/Store/Actions/importSeriesActions.js index 04db50092..347d7b572 100644 --- a/frontend/src/Store/Actions/importSeriesActions.js +++ b/frontend/src/Store/Actions/importSeriesActions.js @@ -221,12 +221,12 @@ export const actionHandlers = handleThunks({ const addedIds = []; const allNewSeries = ids.reduce((acc, id) => { - const item = _.find(items, { id }); + const item = items.find((i) => i.id === id); const selectedSeries = item.selectedSeries; // Make sure we have a selected series and // the same series hasn't been added yet. - if (selectedSeries && !_.some(acc, { tvdbId: selectedSeries.tvdbId })) { + if (selectedSeries && !acc.some((a) => a.tvdbId === selectedSeries.tvdbId)) { const newSeries = getNewSeries(_.cloneDeep(selectedSeries), item); newSeries.path = item.path; @@ -318,7 +318,7 @@ export const reducers = createHandleActions({ [SET_IMPORT_SERIES_VALUE]: function(state, { payload }) { const newState = getSectionState(state, section); const items = newState.items; - const index = _.findIndex(items, { id: payload.id }); + const index = items.findIndex((item) => item.id === payload.id); newState.items = [...items];