1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-10-30 07:22:35 +01:00

Fixed: Import series failing to add items to process

This commit is contained in:
Mark McDowall 2020-04-20 09:35:35 -07:00
parent 42343d5283
commit 97ec184754
2 changed files with 6 additions and 5 deletions

View File

@ -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;
}

View File

@ -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];