Convert store selectors to Typescript
This commit is contained in:
parent
94c6b0fde3
commit
a57b35a196
|
@ -1,11 +1,13 @@
|
||||||
import InteractiveImportAppState from 'App/State/InteractiveImportAppState';
|
import InteractiveImportAppState from 'App/State/InteractiveImportAppState';
|
||||||
import CalendarAppState from './CalendarAppState';
|
import CalendarAppState from './CalendarAppState';
|
||||||
|
import CommandAppState from './CommandAppState';
|
||||||
import EpisodeFilesAppState from './EpisodeFilesAppState';
|
import EpisodeFilesAppState from './EpisodeFilesAppState';
|
||||||
import EpisodesAppState from './EpisodesAppState';
|
import EpisodesAppState from './EpisodesAppState';
|
||||||
import ParseAppState from './ParseAppState';
|
import ParseAppState from './ParseAppState';
|
||||||
import QueueAppState from './QueueAppState';
|
import QueueAppState from './QueueAppState';
|
||||||
import SeriesAppState, { SeriesIndexAppState } from './SeriesAppState';
|
import SeriesAppState, { SeriesIndexAppState } from './SeriesAppState';
|
||||||
import SettingsAppState from './SettingsAppState';
|
import SettingsAppState from './SettingsAppState';
|
||||||
|
import SystemAppState from './SystemAppState';
|
||||||
import TagsAppState from './TagsAppState';
|
import TagsAppState from './TagsAppState';
|
||||||
|
|
||||||
interface FilterBuilderPropOption {
|
interface FilterBuilderPropOption {
|
||||||
|
@ -42,15 +44,17 @@ export interface CustomFilter {
|
||||||
|
|
||||||
interface AppState {
|
interface AppState {
|
||||||
calendar: CalendarAppState;
|
calendar: CalendarAppState;
|
||||||
episodesSelection: EpisodesAppState;
|
commands: CommandAppState;
|
||||||
episodeFiles: EpisodeFilesAppState;
|
episodeFiles: EpisodeFilesAppState;
|
||||||
|
episodesSelection: EpisodesAppState;
|
||||||
interactiveImport: InteractiveImportAppState;
|
interactiveImport: InteractiveImportAppState;
|
||||||
parse: ParseAppState;
|
parse: ParseAppState;
|
||||||
|
queue: QueueAppState;
|
||||||
|
series: SeriesAppState;
|
||||||
seriesIndex: SeriesIndexAppState;
|
seriesIndex: SeriesIndexAppState;
|
||||||
settings: SettingsAppState;
|
settings: SettingsAppState;
|
||||||
series: SeriesAppState;
|
system: SystemAppState;
|
||||||
tags: TagsAppState;
|
tags: TagsAppState;
|
||||||
queue: QueueAppState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AppState;
|
export default AppState;
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import AppSectionState from 'App/State/AppSectionState';
|
||||||
|
import Command from 'Commands/Command';
|
||||||
|
|
||||||
|
export type CommandAppState = AppSectionState<Command>;
|
||||||
|
|
||||||
|
export default CommandAppState;
|
|
@ -1,5 +1,6 @@
|
||||||
import AppSectionState, {
|
import AppSectionState, {
|
||||||
AppSectionDeleteState,
|
AppSectionDeleteState,
|
||||||
|
AppSectionItemState,
|
||||||
AppSectionSaveState,
|
AppSectionSaveState,
|
||||||
AppSectionSchemaState,
|
AppSectionSchemaState,
|
||||||
} from 'App/State/AppSectionState';
|
} from 'App/State/AppSectionState';
|
||||||
|
@ -35,16 +36,16 @@ export interface QualityProfilesAppState
|
||||||
AppSectionSchemaState<QualityProfile> {}
|
AppSectionSchemaState<QualityProfile> {}
|
||||||
|
|
||||||
export type LanguageSettingsAppState = AppSectionState<Language>;
|
export type LanguageSettingsAppState = AppSectionState<Language>;
|
||||||
export type UiSettingsAppState = AppSectionState<UiSettings>;
|
export type UiSettingsAppState = AppSectionItemState<UiSettings>;
|
||||||
|
|
||||||
interface SettingsAppState {
|
interface SettingsAppState {
|
||||||
downloadClients: DownloadClientAppState;
|
downloadClients: DownloadClientAppState;
|
||||||
importLists: ImportListAppState;
|
importLists: ImportListAppState;
|
||||||
indexers: IndexerAppState;
|
indexers: IndexerAppState;
|
||||||
|
languages: LanguageSettingsAppState;
|
||||||
notifications: NotificationAppState;
|
notifications: NotificationAppState;
|
||||||
language: LanguageSettingsAppState;
|
|
||||||
uiSettings: UiSettingsAppState;
|
|
||||||
qualityProfiles: QualityProfilesAppState;
|
qualityProfiles: QualityProfilesAppState;
|
||||||
|
ui: UiSettingsAppState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SettingsAppState;
|
export default SettingsAppState;
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import SystemStatus from 'typings/SystemStatus';
|
||||||
|
import { AppSectionItemState } from './AppSectionState';
|
||||||
|
|
||||||
|
export type SystemStatusAppState = AppSectionItemState<SystemStatus>;
|
||||||
|
|
||||||
|
interface SystemAppState {
|
||||||
|
status: SystemStatusAppState;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SystemAppState;
|
|
@ -1,12 +1,32 @@
|
||||||
import ModelBase from 'App/ModelBase';
|
import ModelBase from 'App/ModelBase';
|
||||||
import AppSectionState, {
|
import AppSectionState, {
|
||||||
AppSectionDeleteState,
|
AppSectionDeleteState,
|
||||||
|
AppSectionSaveState,
|
||||||
} from 'App/State/AppSectionState';
|
} from 'App/State/AppSectionState';
|
||||||
|
|
||||||
export interface Tag extends ModelBase {
|
export interface Tag extends ModelBase {
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TagsAppState extends AppSectionState<Tag>, AppSectionDeleteState {}
|
export interface TagDetail extends ModelBase {
|
||||||
|
label: string;
|
||||||
|
autoTagIds: number[];
|
||||||
|
delayProfileIds: number[];
|
||||||
|
downloadClientIds: [];
|
||||||
|
importListIds: number[];
|
||||||
|
indexerIds: number[];
|
||||||
|
notificationIds: number[];
|
||||||
|
restrictionIds: number[];
|
||||||
|
seriesIds: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TagDetailAppState
|
||||||
|
extends AppSectionState<TagDetail>,
|
||||||
|
AppSectionDeleteState,
|
||||||
|
AppSectionSaveState {}
|
||||||
|
|
||||||
|
interface TagsAppState extends AppSectionState<Tag>, AppSectionDeleteState {
|
||||||
|
details: TagDetailAppState;
|
||||||
|
}
|
||||||
|
|
||||||
export default TagsAppState;
|
export default TagsAppState;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { useSelector } from 'react-redux';
|
||||||
import { icons } from 'Helpers/Props';
|
import { icons } from 'Helpers/Props';
|
||||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||||
import dimensions from 'Styles/Variables/dimensions';
|
import dimensions from 'Styles/Variables/dimensions';
|
||||||
|
import QualityProfile from 'typings/QualityProfile';
|
||||||
import { UiSettings } from 'typings/UiSettings';
|
import { UiSettings } from 'typings/UiSettings';
|
||||||
import formatDateTime from 'Utilities/Date/formatDateTime';
|
import formatDateTime from 'Utilities/Date/formatDateTime';
|
||||||
import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
||||||
|
@ -36,7 +37,7 @@ interface SeriesIndexOverviewInfoProps {
|
||||||
monitored: boolean;
|
monitored: boolean;
|
||||||
nextAiring?: string;
|
nextAiring?: string;
|
||||||
network?: string;
|
network?: string;
|
||||||
qualityProfile: object;
|
qualityProfile?: QualityProfile;
|
||||||
previousAiring?: string;
|
previousAiring?: string;
|
||||||
added?: string;
|
added?: string;
|
||||||
seasonCount: number;
|
seasonCount: number;
|
||||||
|
@ -115,13 +116,10 @@ function getInfoRowProps(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name === 'qualityProfileId') {
|
if (name === 'qualityProfileId' && !!props.qualityProfile?.name) {
|
||||||
return {
|
return {
|
||||||
title: 'Quality Profile',
|
title: 'Quality Profile',
|
||||||
iconName: icons.PROFILE,
|
iconName: icons.PROFILE,
|
||||||
// TODO: Type QualityProfile
|
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
// @ts-ignore ts(2339)
|
|
||||||
label: props.qualityProfile.name,
|
label: props.qualityProfile.name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ function SeriesIndexPoster(props: SeriesIndexPosterProps) {
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{showQualityProfile ? (
|
{showQualityProfile && !!qualityProfile?.name ? (
|
||||||
<div className={styles.title} title={translate('QualityProfile')}>
|
<div className={styles.title} title={translate('QualityProfile')}>
|
||||||
{qualityProfile.name}
|
{qualityProfile.name}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -11,7 +11,7 @@ interface SeriesIndexPosterInfoProps {
|
||||||
originalLanguage?: Language;
|
originalLanguage?: Language;
|
||||||
network?: string;
|
network?: string;
|
||||||
showQualityProfile: boolean;
|
showQualityProfile: boolean;
|
||||||
qualityProfile: QualityProfile;
|
qualityProfile?: QualityProfile;
|
||||||
previousAiring?: string;
|
previousAiring?: string;
|
||||||
added?: string;
|
added?: string;
|
||||||
seasonCount: number;
|
seasonCount: number;
|
||||||
|
@ -58,7 +58,11 @@ function SeriesIndexPosterInfo(props: SeriesIndexPosterInfoProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortKey === 'qualityProfileId' && !showQualityProfile) {
|
if (
|
||||||
|
sortKey === 'qualityProfileId' &&
|
||||||
|
!showQualityProfile &&
|
||||||
|
!!qualityProfile?.name
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.info} title={translate('QualityProfile')}>
|
<div className={styles.info} title={translate('QualityProfile')}>
|
||||||
{qualityProfile.name}
|
{qualityProfile.name}
|
||||||
|
|
|
@ -242,7 +242,7 @@ function SeriesIndexRow(props: SeriesIndexRowProps) {
|
||||||
if (name === 'qualityProfileId') {
|
if (name === 'qualityProfileId') {
|
||||||
return (
|
return (
|
||||||
<VirtualTableRowCell key={name} className={styles[name]}>
|
<VirtualTableRowCell key={name} className={styles[name]}>
|
||||||
{qualityProfile.name}
|
{qualityProfile?.name ?? ''}
|
||||||
</VirtualTableRowCell>
|
</VirtualTableRowCell>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createAllSeriesSelector() {
|
function createAllSeriesSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.series,
|
(state: AppState) => state.series,
|
||||||
(series) => {
|
(series) => {
|
||||||
return series.items;
|
return series.items;
|
||||||
}
|
}
|
|
@ -2,13 +2,10 @@ import { createSelector } from 'reselect';
|
||||||
import { isCommandExecuting } from 'Utilities/Command';
|
import { isCommandExecuting } from 'Utilities/Command';
|
||||||
import createCommandSelector from './createCommandSelector';
|
import createCommandSelector from './createCommandSelector';
|
||||||
|
|
||||||
function createCommandExecutingSelector(name, contraints = {}) {
|
function createCommandExecutingSelector(name: string, contraints = {}) {
|
||||||
return createSelector(
|
return createSelector(createCommandSelector(name, contraints), (command) => {
|
||||||
createCommandSelector(name, contraints),
|
return isCommandExecuting(command);
|
||||||
(command) => {
|
});
|
||||||
return isCommandExecuting(command);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createCommandExecutingSelector;
|
export default createCommandExecutingSelector;
|
|
@ -1,14 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import { findCommand } from 'Utilities/Command';
|
|
||||||
import createCommandsSelector from './createCommandsSelector';
|
|
||||||
|
|
||||||
function createCommandSelector(name, contraints = {}) {
|
|
||||||
return createSelector(
|
|
||||||
createCommandsSelector(),
|
|
||||||
(commands) => {
|
|
||||||
return findCommand(commands, { name, ...contraints });
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createCommandSelector;
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import { findCommand } from 'Utilities/Command';
|
||||||
|
import createCommandsSelector from './createCommandsSelector';
|
||||||
|
|
||||||
|
function createCommandSelector(name: string, contraints = {}) {
|
||||||
|
return createSelector(createCommandsSelector(), (commands) => {
|
||||||
|
return findCommand(commands, { name, ...contraints });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createCommandSelector;
|
|
@ -1,8 +1,9 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createCommandsSelector() {
|
function createCommandsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.commands,
|
(state: AppState) => state.commands,
|
||||||
(commands) => {
|
(commands) => {
|
||||||
return commands.items;
|
return commands.items;
|
||||||
}
|
}
|
|
@ -1,9 +0,0 @@
|
||||||
import _ from 'lodash';
|
|
||||||
import { createSelectorCreator, defaultMemoize } from 'reselect';
|
|
||||||
|
|
||||||
const createDeepEqualSelector = createSelectorCreator(
|
|
||||||
defaultMemoize,
|
|
||||||
_.isEqual
|
|
||||||
);
|
|
||||||
|
|
||||||
export default createDeepEqualSelector;
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { isEqual } from 'lodash';
|
||||||
|
import { createSelectorCreator, defaultMemoize } from 'reselect';
|
||||||
|
|
||||||
|
const createDeepEqualSelector = createSelectorCreator(defaultMemoize, isEqual);
|
||||||
|
|
||||||
|
export default createDeepEqualSelector;
|
|
@ -1,17 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
function createEpisodeFileSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state, { episodeFileId }) => episodeFileId,
|
|
||||||
(state) => state.episodeFiles,
|
|
||||||
(episodeFileId, episodeFiles) => {
|
|
||||||
if (!episodeFileId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return episodeFiles.items.find((episodeFile) => episodeFile.id === episodeFileId);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createEpisodeFileSelector;
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
|
function createEpisodeFileSelector() {
|
||||||
|
return createSelector(
|
||||||
|
(_: AppState, { episodeFileId }: { episodeFileId: number }) =>
|
||||||
|
episodeFileId,
|
||||||
|
(state: AppState) => state.episodeFiles,
|
||||||
|
(episodeFileId, episodeFiles) => {
|
||||||
|
if (!episodeFileId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return episodeFiles.items.find(
|
||||||
|
(episodeFile) => episodeFile.id === episodeFileId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createEpisodeFileSelector;
|
|
@ -1,9 +1,10 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
import { isCommandExecuting } from 'Utilities/Command';
|
import { isCommandExecuting } from 'Utilities/Command';
|
||||||
|
|
||||||
function createExecutingCommandsSelector() {
|
function createExecutingCommandsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.commands.items,
|
(state: AppState) => state.commands.items,
|
||||||
(commands) => {
|
(commands) => {
|
||||||
return commands.filter((command) => isCommandExecuting(command));
|
return commands.filter((command) => isCommandExecuting(command));
|
||||||
}
|
}
|
|
@ -1,13 +1,14 @@
|
||||||
import _ from 'lodash';
|
import { some } from 'lodash';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
import createAllSeriesSelector from './createAllSeriesSelector';
|
import createAllSeriesSelector from './createAllSeriesSelector';
|
||||||
|
|
||||||
function createExistingSeriesSelector() {
|
function createExistingSeriesSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { tvdbId }) => tvdbId,
|
(_: AppState, { tvdbId }: { tvdbId: number }) => tvdbId,
|
||||||
createAllSeriesSelector(),
|
createAllSeriesSelector(),
|
||||||
(tvdbId, series) => {
|
(tvdbId, series) => {
|
||||||
return _.some(series, { tvdbId });
|
return some(series, { tvdbId });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -1,27 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
function createLanguagesSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state) => state.settings.languages,
|
|
||||||
(languages) => {
|
|
||||||
const {
|
|
||||||
isFetching,
|
|
||||||
isPopulated,
|
|
||||||
error,
|
|
||||||
items
|
|
||||||
} = languages;
|
|
||||||
|
|
||||||
const filterItems = ['Any'];
|
|
||||||
const filteredLanguages = items.filter((lang) => !filterItems.includes(lang.name));
|
|
||||||
|
|
||||||
return {
|
|
||||||
isFetching,
|
|
||||||
isPopulated,
|
|
||||||
error,
|
|
||||||
items: filteredLanguages
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createLanguagesSelector;
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
|
function createLanguagesSelector() {
|
||||||
|
return createSelector(
|
||||||
|
(state: AppState) => state.settings.languages,
|
||||||
|
(languages) => {
|
||||||
|
const { isFetching, isPopulated, error, items } = languages;
|
||||||
|
|
||||||
|
const filterItems = ['Any'];
|
||||||
|
const filteredLanguages = items.filter(
|
||||||
|
(lang) => !filterItems.includes(lang.name)
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
isFetching,
|
||||||
|
isPopulated,
|
||||||
|
error,
|
||||||
|
items: filteredLanguages,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createLanguagesSelector;
|
|
@ -1,19 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import createAllSeriesSelector from './createAllSeriesSelector';
|
|
||||||
|
|
||||||
function createProfileInUseSelector(profileProp) {
|
|
||||||
return createSelector(
|
|
||||||
(state, { id }) => id,
|
|
||||||
createAllSeriesSelector(),
|
|
||||||
(state) => state.settings.importLists.items,
|
|
||||||
(id, series, lists) => {
|
|
||||||
if (!id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return series.some((s) => s[profileProp] === id) || lists.some((list) => list[profileProp] === id);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createProfileInUseSelector;
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
import Series from 'Series/Series';
|
||||||
|
import ImportList from 'typings/ImportList';
|
||||||
|
import createAllSeriesSelector from './createAllSeriesSelector';
|
||||||
|
|
||||||
|
function createProfileInUseSelector(profileProp: string) {
|
||||||
|
return createSelector(
|
||||||
|
(_: AppState, { id }: { id: number }) => id,
|
||||||
|
createAllSeriesSelector(),
|
||||||
|
(state: AppState) => state.settings.importLists.items,
|
||||||
|
(id, series, lists) => {
|
||||||
|
if (!id) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
series.some((s) => s[profileProp as keyof Series] === id) ||
|
||||||
|
lists.some((list) => list[profileProp as keyof ImportList] === id)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createProfileInUseSelector;
|
|
@ -1,26 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
|
|
||||||
export function createQualityProfileSelectorForHook(qualityProfileId) {
|
|
||||||
return createSelector(
|
|
||||||
(state) => state.settings.qualityProfiles.items,
|
|
||||||
(qualityProfiles) => {
|
|
||||||
return qualityProfiles.find((profile) => {
|
|
||||||
return profile.id === qualityProfileId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function createQualityProfileSelector() {
|
|
||||||
return createSelector(
|
|
||||||
(state, { qualityProfileId }) => qualityProfileId,
|
|
||||||
(state) => state.settings.qualityProfiles.items,
|
|
||||||
(qualityProfileId, qualityProfiles) => {
|
|
||||||
return qualityProfiles.find((profile) => {
|
|
||||||
return profile.id === qualityProfileId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createQualityProfileSelector;
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
|
export function createQualityProfileSelectorForHook(qualityProfileId: number) {
|
||||||
|
return createSelector(
|
||||||
|
(state: AppState) => state.settings.qualityProfiles.items,
|
||||||
|
(qualityProfiles) => {
|
||||||
|
return qualityProfiles.find((profile) => profile.id === qualityProfileId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function createQualityProfileSelector() {
|
||||||
|
return createSelector(
|
||||||
|
(_: AppState, { qualityProfileId }: { qualityProfileId: number }) =>
|
||||||
|
qualityProfileId,
|
||||||
|
(state: AppState) => state.settings.qualityProfiles.items,
|
||||||
|
(qualityProfileId, qualityProfiles) => {
|
||||||
|
return qualityProfiles.find((profile) => profile.id === qualityProfileId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createQualityProfileSelector;
|
|
@ -1,17 +1,16 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createQueueItemSelector() {
|
function createQueueItemSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { episodeId }) => episodeId,
|
(_: AppState, { episodeId }: { episodeId: number }) => episodeId,
|
||||||
(state) => state.queue.details.items,
|
(state: AppState) => state.queue.details.items,
|
||||||
(episodeId, details) => {
|
(episodeId, details) => {
|
||||||
if (!episodeId || !details) {
|
if (!episodeId || !details) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return details.find((item) => {
|
return details.find((item) => item.episodeId === episodeId);
|
||||||
return item.episodeId === episodeId;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -2,12 +2,9 @@ import { createSelector } from 'reselect';
|
||||||
import createAllSeriesSelector from './createAllSeriesSelector';
|
import createAllSeriesSelector from './createAllSeriesSelector';
|
||||||
|
|
||||||
function createSeriesCountSelector() {
|
function createSeriesCountSelector() {
|
||||||
return createSelector(
|
return createSelector(createAllSeriesSelector(), (series) => {
|
||||||
createAllSeriesSelector(),
|
return series.length;
|
||||||
(series) => {
|
});
|
||||||
return series.length;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createSeriesCountSelector;
|
export default createSeriesCountSelector;
|
|
@ -1,16 +0,0 @@
|
||||||
import { createSelector } from 'reselect';
|
|
||||||
import { createSeriesSelectorForHook } from './createSeriesSelector';
|
|
||||||
|
|
||||||
function createSeriesQualityProfileSelector(seriesId) {
|
|
||||||
return createSelector(
|
|
||||||
(state) => state.settings.qualityProfiles.items,
|
|
||||||
createSeriesSelectorForHook(seriesId),
|
|
||||||
(qualityProfiles, series = {}) => {
|
|
||||||
return qualityProfiles.find((profile) => {
|
|
||||||
return profile.id === series.qualityProfileId;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default createSeriesQualityProfileSelector;
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
import Series from 'Series/Series';
|
||||||
|
import { createSeriesSelectorForHook } from './createSeriesSelector';
|
||||||
|
|
||||||
|
function createSeriesQualityProfileSelector(seriesId: number) {
|
||||||
|
return createSelector(
|
||||||
|
(state: AppState) => state.settings.qualityProfiles.items,
|
||||||
|
createSeriesSelectorForHook(seriesId),
|
||||||
|
(qualityProfiles, series = {} as Series) => {
|
||||||
|
return qualityProfiles.find(
|
||||||
|
(profile) => profile.id === series.qualityProfileId
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default createSeriesQualityProfileSelector;
|
|
@ -1,8 +1,9 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createSystemStatusSelector() {
|
function createSystemStatusSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.system.status,
|
(state: AppState) => state.system.status,
|
||||||
(status) => {
|
(status) => {
|
||||||
return status.item;
|
return status.item;
|
||||||
}
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createTagDetailsSelector() {
|
function createTagDetailsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { id }) => id,
|
(_: AppState, { id }: { id: number }) => id,
|
||||||
(state) => state.tags.details.items,
|
(state: AppState) => state.tags.details.items,
|
||||||
(id, tagDetails) => {
|
(id, tagDetails) => {
|
||||||
return tagDetails.find((t) => t.id === id);
|
return tagDetails.find((t) => t.id === id);
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createTagsSelector() {
|
function createTagsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.tags.items,
|
(state: AppState) => state.tags.items,
|
||||||
(tags) => {
|
(tags) => {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import AppState from 'App/State/AppState';
|
||||||
|
|
||||||
function createUISettingsSelector() {
|
function createUISettingsSelector() {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state) => state.settings.ui,
|
(state: AppState) => state.settings.ui,
|
||||||
(ui) => {
|
(ui) => {
|
||||||
return ui.item;
|
return ui.item;
|
||||||
}
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
interface SystemStatus {
|
||||||
|
appData: string;
|
||||||
|
appName: string;
|
||||||
|
authentication: string;
|
||||||
|
branch: string;
|
||||||
|
buildTime: string;
|
||||||
|
instanceName: string;
|
||||||
|
isAdmin: boolean;
|
||||||
|
isDebug: boolean;
|
||||||
|
isDocker: boolean;
|
||||||
|
isLinux: boolean;
|
||||||
|
isNetCore: boolean;
|
||||||
|
isOsx: boolean;
|
||||||
|
isProduction: boolean;
|
||||||
|
isUserInteractive: boolean;
|
||||||
|
isWindows: boolean;
|
||||||
|
migrationVersion: number;
|
||||||
|
mode: string;
|
||||||
|
osName: string;
|
||||||
|
osVersion: string;
|
||||||
|
packageUpdateMechanism: string;
|
||||||
|
runtimeName: string;
|
||||||
|
runtimeVersion: string;
|
||||||
|
sqliteVersion: string;
|
||||||
|
startTime: string;
|
||||||
|
startupPath: string;
|
||||||
|
urlBase: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SystemStatus;
|
Loading…
Reference in New Issue