mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-23 22:25:14 -04:00
New: Download History
Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
@@ -73,11 +73,12 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||
const newState = getSectionState(state, payloadSection);
|
||||
const items = newState.items;
|
||||
|
||||
if (!newState.itemMap) {
|
||||
newState.itemMap = createItemMap(items);
|
||||
}
|
||||
|
||||
const index = payload.id in newState.itemMap ? newState.itemMap[payload.id] : -1;
|
||||
// Client side collections that are created by adding items to an
|
||||
// existing array may not have an itemMap, the array is probably empty,
|
||||
// but on the offchance it's not create a new item map based on the
|
||||
// items in the array.
|
||||
const itemMap = newState.itemMap ?? createItemMap(items);
|
||||
const index = payload.id in itemMap ? itemMap[payload.id] : -1;
|
||||
|
||||
newState.items = [...items];
|
||||
|
||||
@@ -96,6 +97,7 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||
} else if (!updateOnly) {
|
||||
const newIndex = newState.items.push({ ...otherProps }) - 1;
|
||||
|
||||
newState.itemMap = { ...itemMap };
|
||||
newState.itemMap[payload.id] = newIndex;
|
||||
}
|
||||
|
||||
@@ -152,7 +154,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));
|
||||
|
||||
Reference in New Issue
Block a user