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:
committed by
Mark McDowall
parent
de56862bb9
commit
d022679b7d
@@ -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;
|
||||
Reference in New Issue
Block a user