mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Fixed: Faster movie selector
This commit is contained in:
parent
3ed442ec0f
commit
de491aa4b3
2 changed files with 8 additions and 4 deletions
|
@ -42,6 +42,7 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||||
|
|
||||||
if (_.isArray(payload.data)) {
|
if (_.isArray(payload.data)) {
|
||||||
newState.items = payload.data;
|
newState.items = payload.data;
|
||||||
|
newState.itemMap = _.zipObject(_.map(payload.data, 'id'), _.range(payload.data.length));
|
||||||
} else {
|
} else {
|
||||||
newState.item = payload.data;
|
newState.item = payload.data;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +76,7 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||||
newState.items.splice(index, 1, { ...item, ...otherProps });
|
newState.items.splice(index, 1, { ...item, ...otherProps });
|
||||||
} else if (!updateOnly) {
|
} else if (!updateOnly) {
|
||||||
newState.items.push({ ...otherProps });
|
newState.items.push({ ...otherProps });
|
||||||
|
newState.itemMap = _.zipObject(_.map(newState.items, 'id'), _.range(newState.items.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateSectionState(state, payloadSection, newState);
|
return updateSectionState(state, payloadSection, newState);
|
||||||
|
@ -111,6 +113,8 @@ export default function createHandleActions(handlers, defaultState, section) {
|
||||||
newState.items = [...newState.items];
|
newState.items = [...newState.items];
|
||||||
_.remove(newState.items, { id: payload.id });
|
_.remove(newState.items, { id: payload.id });
|
||||||
|
|
||||||
|
newState.itemMap = _.zipObject(_.map(newState.items, 'id'), _.range(newState.items.length));
|
||||||
|
|
||||||
return updateSectionState(state, payloadSection, newState);
|
return updateSectionState(state, payloadSection, newState);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createAllArtistSelector from './createAllArtistSelector';
|
|
||||||
|
|
||||||
function createArtistSelector() {
|
function createArtistSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { artistId }) => artistId,
|
(state, { artistId }) => artistId,
|
||||||
createAllArtistSelector(),
|
(state) => state.artist.itemMap,
|
||||||
(artistId, allArtists) => {
|
(state) => state.artist.items,
|
||||||
return allArtists.find((artist) => artist.id === artistId );
|
(artistId, itemMap, allArtists) => {
|
||||||
|
return allArtists[itemMap[artistId]];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue