Fixed: Import series failing to add items to process

pull/3684/head
Mark McDowall 5 years ago
parent 42343d5283
commit 97ec184754

@ -72,8 +72,9 @@ export default function createHandleActions(handlers, defaultState, section) {
if (section === baseSection) { if (section === baseSection) {
const newState = getSectionState(state, payloadSection); const newState = getSectionState(state, payloadSection);
const items = newState.items; 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]; newState.items = [...items];
@ -92,7 +93,7 @@ export default function createHandleActions(handlers, defaultState, section) {
} else if (!updateOnly) { } else if (!updateOnly) {
const newIndex = newState.items.push({ ...otherProps }) - 1; const newIndex = newState.items.push({ ...otherProps }) - 1;
newState.itemMap = { ...newState.itemMap }; newState.itemMap = { ...itemMap };
newState.itemMap[payload.id] = newIndex; newState.itemMap[payload.id] = newIndex;
} }

@ -221,12 +221,12 @@ export const actionHandlers = handleThunks({
const addedIds = []; const addedIds = [];
const allNewSeries = ids.reduce((acc, id) => { const allNewSeries = ids.reduce((acc, id) => {
const item = _.find(items, { id }); const item = items.find((i) => i.id === id);
const selectedSeries = item.selectedSeries; const selectedSeries = item.selectedSeries;
// Make sure we have a selected series and // Make sure we have a selected series and
// the same series hasn't been added yet. // 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); const newSeries = getNewSeries(_.cloneDeep(selectedSeries), item);
newSeries.path = item.path; newSeries.path = item.path;
@ -318,7 +318,7 @@ export const reducers = createHandleActions({
[SET_IMPORT_SERIES_VALUE]: function(state, { payload }) { [SET_IMPORT_SERIES_VALUE]: function(state, { payload }) {
const newState = getSectionState(state, section); const newState = getSectionState(state, section);
const items = newState.items; const items = newState.items;
const index = _.findIndex(items, { id: payload.id }); const index = items.findIndex((item) => item.id === payload.id);
newState.items = [...items]; newState.items = [...items];

Loading…
Cancel
Save