(cherry picked from commit a57b35a1966266b49d1241474fe3b69523f70474)pull/8909/head
parent
abad6a9f18
commit
43a0e75acf
@ -0,0 +1,6 @@
|
||||
import AppSectionState from 'App/State/AppSectionState';
|
||||
import Command from 'Commands/Command';
|
||||
|
||||
export type CommandAppState = AppSectionState<Command>;
|
||||
|
||||
export default CommandAppState;
|
@ -0,0 +1,6 @@
|
||||
import AppSectionState from 'App/State/AppSectionState';
|
||||
import MovieCollection from 'typings/MovieCollection';
|
||||
|
||||
type MovieCollectionAppState = AppSectionState<MovieCollection>;
|
||||
|
||||
export default MovieCollectionAppState;
|
@ -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 AppSectionState, {
|
||||
AppSectionDeleteState,
|
||||
AppSectionSaveState,
|
||||
} from 'App/State/AppSectionState';
|
||||
|
||||
export interface Tag extends ModelBase {
|
||||
label: string;
|
||||
}
|
||||
|
||||
interface TagsAppState extends AppSectionState<Tag>, AppSectionDeleteState {}
|
||||
export interface TagDetail extends ModelBase {
|
||||
label: string;
|
||||
autoTagIds: number[];
|
||||
delayProfileIds: number[];
|
||||
downloadClientIds: number[];
|
||||
importListIds: number[];
|
||||
indexerIds: number[];
|
||||
movieIds: number[];
|
||||
notificationIds: number[];
|
||||
restrictionIds: number[];
|
||||
}
|
||||
|
||||
export interface TagDetailAppState
|
||||
extends AppSectionState<TagDetail>,
|
||||
AppSectionDeleteState,
|
||||
AppSectionSaveState {}
|
||||
|
||||
interface TagsAppState extends AppSectionState<Tag>, AppSectionDeleteState {
|
||||
details: TagDetailAppState;
|
||||
}
|
||||
|
||||
export default TagsAppState;
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createAllMoviesSelector() {
|
||||
return createSelector(
|
||||
(state) => state.movies,
|
||||
(state: AppState) => state.movies,
|
||||
(movies) => {
|
||||
return movies.items;
|
||||
}
|
@ -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 AppState from 'App/State/AppState';
|
||||
|
||||
function createCommandsSelector() {
|
||||
return createSelector(
|
||||
(state) => state.commands,
|
||||
(state: AppState) => state.commands,
|
||||
(commands) => {
|
||||
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,9 +1,10 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
import { isCommandExecuting } from 'Utilities/Command';
|
||||
|
||||
function createExecutingCommandsSelector() {
|
||||
return createSelector(
|
||||
(state) => state.commands.items,
|
||||
(state: AppState) => state.commands.items,
|
||||
(commands) => {
|
||||
return commands.filter((command) => isCommandExecuting(command));
|
||||
}
|
@ -1,13 +1,14 @@
|
||||
import _ from 'lodash';
|
||||
import { some } from 'lodash';
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
import createAllMoviesSelector from './createAllMoviesSelector';
|
||||
|
||||
function createExistingMovieSelector() {
|
||||
return createSelector(
|
||||
(state, { tmdbId }) => tmdbId,
|
||||
(_: AppState, { tmdbId }: { tmdbId: number }) => tmdbId,
|
||||
createAllMoviesSelector(),
|
||||
(tmdbId, movies) => {
|
||||
return _.some(movies, { tmdbId });
|
||||
return some(movies, { tmdbId });
|
||||
}
|
||||
);
|
||||
}
|
@ -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,18 +1,19 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
import createAllMoviesSelector from './createAllMoviesSelector';
|
||||
|
||||
function createMovieCountSelector() {
|
||||
return createSelector(
|
||||
createAllMoviesSelector(),
|
||||
(state) => state.movies.error,
|
||||
(state) => state.movies.isFetching,
|
||||
(state) => state.movies.isPopulated,
|
||||
(state: AppState) => state.movies.error,
|
||||
(state: AppState) => state.movies.isFetching,
|
||||
(state: AppState) => state.movies.isPopulated,
|
||||
(movies, error, isFetching, isPopulated) => {
|
||||
return {
|
||||
count: movies.length,
|
||||
error,
|
||||
isFetching,
|
||||
isPopulated
|
||||
isPopulated,
|
||||
};
|
||||
}
|
||||
);
|
@ -1,9 +1,10 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createMovieFileSelector() {
|
||||
return createSelector(
|
||||
(state, { movieFileId }) => movieFileId,
|
||||
(state) => state.movieFiles,
|
||||
(_: AppState, { movieFileId }: { movieFileId: number }) => movieFileId,
|
||||
(state: AppState) => state.movieFiles,
|
||||
(movieFileId, movieFiles) => {
|
||||
if (!movieFileId) {
|
||||
return;
|
@ -1,16 +0,0 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import { createMovieSelectorForHook } from './createMovieSelector';
|
||||
|
||||
function createMovieQualityProfileSelector(movieId) {
|
||||
return createSelector(
|
||||
(state) => state.settings.qualityProfiles.items,
|
||||
createMovieSelectorForHook(movieId),
|
||||
(qualityProfiles, movie = {}) => {
|
||||
return qualityProfiles.find((profile) => {
|
||||
return profile.id === movie.qualityProfileId;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createMovieQualityProfileSelector;
|
@ -0,0 +1,18 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import appState from 'App/State/AppState';
|
||||
import Movie from 'Movie/Movie';
|
||||
import { createMovieSelectorForHook } from './createMovieSelector';
|
||||
|
||||
function createMovieQualityProfileSelector(movieId: number) {
|
||||
return createSelector(
|
||||
(state: appState) => state.settings.qualityProfiles.items,
|
||||
createMovieSelectorForHook(movieId),
|
||||
(qualityProfiles, movie = {} as Movie) => {
|
||||
return qualityProfiles.find(
|
||||
(profile) => profile.id === movie.qualityProfileId
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createMovieQualityProfileSelector;
|
@ -1,25 +0,0 @@
|
||||
import _ from 'lodash';
|
||||
import { createSelector } from 'reselect';
|
||||
import createAllMoviesSelector from './createAllMoviesSelector';
|
||||
|
||||
function createProfileInUseSelector(profileProp) {
|
||||
return createSelector(
|
||||
(state, { id }) => id,
|
||||
createAllMoviesSelector(),
|
||||
(state) => state.settings.importLists.items,
|
||||
(state) => state.movieCollections.items,
|
||||
(id, movies, lists, collections) => {
|
||||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_.some(movies, { [profileProp]: id }) || _.some(lists, { [profileProp]: id }) || _.some(collections, { [profileProp]: id })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createProfileInUseSelector;
|
@ -0,0 +1,31 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
import Movie from 'Movie/Movie';
|
||||
import ImportList from 'typings/ImportList';
|
||||
import MovieCollection from 'typings/MovieCollection';
|
||||
import createAllMoviesSelector from './createAllMoviesSelector';
|
||||
|
||||
function createProfileInUseSelector(profileProp: string) {
|
||||
return createSelector(
|
||||
(_: AppState, { id }: { id: number }) => id,
|
||||
createAllMoviesSelector(),
|
||||
(state: AppState) => state.settings.importLists.items,
|
||||
(state: AppState) => state.movieCollections.items,
|
||||
(id, movies, lists, collections) => {
|
||||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
movies.some((m) => m[profileProp as keyof Movie] === id) ||
|
||||
lists.some((list) => list[profileProp as keyof ImportList] === id) ||
|
||||
collections.some(
|
||||
(collection) =>
|
||||
collection[profileProp as keyof MovieCollection] === 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 AppState from 'App/State/AppState';
|
||||
|
||||
function createQueueItemSelector() {
|
||||
return createSelector(
|
||||
(state, { movieId }) => movieId,
|
||||
(state) => state.queue.details.items,
|
||||
(_: AppState, { movieId }: { movieId: number }) => movieId,
|
||||
(state: AppState) => state.queue.details.items,
|
||||
(movieId, details) => {
|
||||
if (!movieId || !details) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return details.find((item) => {
|
||||
return item.movieId === movieId;
|
||||
});
|
||||
return details.find((item) => item.movieId === movieId);
|
||||
}
|
||||
);
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createSystemStatusSelector() {
|
||||
return createSelector(
|
||||
(state) => state.system.status,
|
||||
(state: AppState) => state.system.status,
|
||||
(status) => {
|
||||
return status.item;
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createTagDetailsSelector() {
|
||||
return createSelector(
|
||||
(state, { id }) => id,
|
||||
(state) => state.tags.details.items,
|
||||
(_: AppState, { id }: { id: number }) => id,
|
||||
(state: AppState) => state.tags.details.items,
|
||||
(id, tagDetails) => {
|
||||
return tagDetails.find((t) => t.id === id);
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createTagsSelector() {
|
||||
return createSelector(
|
||||
(state) => state.tags.items,
|
||||
(state: AppState) => state.tags.items,
|
||||
(tags) => {
|
||||
return tags;
|
||||
}
|
@ -1,8 +1,9 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import AppState from 'App/State/AppState';
|
||||
|
||||
function createUISettingsSelector() {
|
||||
return createSelector(
|
||||
(state) => state.settings.ui,
|
||||
(state: AppState) => state.settings.ui,
|
||||
(ui) => {
|
||||
return ui.item;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import ModelBase from 'App/ModelBase';
|
||||
import Movie from 'Movie/Movie';
|
||||
|
||||
interface MovieCollection extends ModelBase {
|
||||
title: string;
|
||||
sortTitle: string;
|
||||
tmdbId: number;
|
||||
overview: string;
|
||||
monitored: boolean;
|
||||
rootFolderPath: string;
|
||||
qualityProfileId: number;
|
||||
movies: Movie[];
|
||||
missingMovies: number;
|
||||
tags: number[];
|
||||
}
|
||||
|
||||
export default MovieCollection;
|
@ -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