1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2026-04-20 21:54:58 -04:00

Refactor Series index to use react-window

This commit is contained in:
Mark McDowall
2023-01-05 18:20:49 -08:00
committed by Mark McDowall
parent de56862bb9
commit d022679b7d
92 changed files with 3527 additions and 4462 deletions
@@ -0,0 +1,51 @@
import { maxBy } from 'lodash';
import { createSelector } from 'reselect';
import { REFRESH_SERIES, SERIES_SEARCH } from 'Commands/commandNames';
import createExecutingCommandsSelector from 'Store/Selectors/createExecutingCommandsSelector';
import createSeriesQualityProfileSelector from 'Store/Selectors/createSeriesQualityProfileSelector';
import createSeriesSelector from 'Store/Selectors/createSeriesSelector';
function createSeriesIndexItemSelector(seriesId: number) {
return createSelector(
createSeriesSelector(seriesId),
createSeriesQualityProfileSelector(seriesId),
createExecutingCommandsSelector(),
(series, qualityProfile, executingCommands) => {
// If a series is deleted this selector may fire before the parent
// selectors, which will result in an undefined series, if that happens
// we want to return early here and again in the render function to avoid
// trying to show a series that has no information available.
if (!series) {
return {};
}
const isRefreshingSeries = executingCommands.some((command) => {
return (
command.name === REFRESH_SERIES && command.body.seriesId === series.id
);
});
const isSearchingSeries = executingCommands.some((command) => {
return (
command.name === SERIES_SEARCH && command.body.seriesId === series.id
);
});
const latestSeason = maxBy(
series.seasons,
(season) => season.seasonNumber
);
return {
series,
qualityProfile,
latestSeason,
isRefreshingSeries,
isSearchingSeries,
};
}
);
}
export default createSeriesIndexItemSelector;