mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Calculate custom formats on demand
This commit is contained in:
@@ -16,6 +16,13 @@ const blacklistedProperties = [
|
||||
'id'
|
||||
];
|
||||
|
||||
function createItemMap(data) {
|
||||
return data.reduce((acc, d, index, array) => {
|
||||
acc[d.id] = index;
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export default function createHandleActions(handlers, defaultState, section) {
|
||||
return handleActions({
|
||||
|
||||
@@ -42,7 +49,7 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||
|
||||
if (_.isArray(payload.data)) {
|
||||
newState.items = payload.data;
|
||||
newState.itemMap = _.zipObject(_.map(payload.data, 'id'), _.range(payload.data.length));
|
||||
newState.itemMap = createItemMap(newState.items);
|
||||
} else {
|
||||
newState.item = payload.data;
|
||||
}
|
||||
@@ -67,7 +74,7 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||
const items = newState.items;
|
||||
|
||||
if (!newState.itemMap) {
|
||||
newState.itemMap = _.zipObject(_.map(items, 'id'), _.range(items.length));
|
||||
newState.itemMap = createItemMap(items);
|
||||
}
|
||||
|
||||
const index = payload.id in newState.itemMap ? newState.itemMap[payload.id] : -1;
|
||||
@@ -126,7 +133,7 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||
newState.items = [...newState.items];
|
||||
_.remove(newState.items, { id: payload.id });
|
||||
|
||||
newState.itemMap = _.zipObject(_.map(newState.items, 'id'), _.range(newState.items.length));
|
||||
newState.itemMap = createItemMap(newState.items);
|
||||
|
||||
return updateSectionState(state, payloadSection, newState);
|
||||
}
|
||||
|
@@ -51,9 +51,9 @@ export const defaultState = {
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'quality.customFormats',
|
||||
label: 'Custom Formats',
|
||||
isSortable: true,
|
||||
name: 'customFormats',
|
||||
label: 'Formats',
|
||||
isSortable: false,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
|
@@ -52,9 +52,9 @@ export const defaultState = {
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'quality.customFormats',
|
||||
label: 'Custom Formats',
|
||||
isSortable: true,
|
||||
name: 'customFormats',
|
||||
label: 'Formats',
|
||||
isSortable: false,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
|
@@ -81,9 +81,9 @@ export const defaultState = {
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
name: 'quality.customFormats',
|
||||
label: 'Custom Formats',
|
||||
isSortable: true,
|
||||
name: 'customFormats',
|
||||
label: 'Formats',
|
||||
isSortable: false,
|
||||
isVisible: true
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user