mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Use interface over type
This commit is contained in:
parent
9d88af3dfe
commit
de4a359c98
21 changed files with 100 additions and 106 deletions
|
@ -1,24 +1,21 @@
|
||||||
import React, { FunctionComponent } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
const createElement = ({ id, className }: IProps) => ({
|
const createElement = ({ className }: IProps) => ({
|
||||||
__html: `<div
|
__html: `<div
|
||||||
is="emby-itemscontainer"
|
is="emby-itemscontainer"
|
||||||
${id}
|
|
||||||
class="${className}"
|
class="${className}"
|
||||||
>
|
>
|
||||||
</div>`
|
</div>`
|
||||||
});
|
});
|
||||||
|
|
||||||
type IProps = {
|
interface IProps {
|
||||||
id?: string;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ItemsContainerElement: FunctionComponent<IProps> = ({ id, className }: IProps) => {
|
const ItemsContainerElement: FC<IProps> = ({ className }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
dangerouslySetInnerHTML={createElement({
|
dangerouslySetInnerHTML={createElement({
|
||||||
id: id ? `id='${id}'` : '',
|
|
||||||
className: className
|
className: className
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,31 +1,29 @@
|
||||||
import React, { FunctionComponent } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
const createScroller = ({ scrollerclassName, dataHorizontal, dataMousewheel, dataCenterfocus, id, className }: IProps) => ({
|
const createScroller = ({ scrollerclassName, dataHorizontal, dataMousewheel, dataCenterfocus, className }: IProps) => ({
|
||||||
__html: `<div is="emby-scroller"
|
__html: `<div is="emby-scroller"
|
||||||
class="${scrollerclassName}"
|
class="${scrollerclassName}"
|
||||||
${dataHorizontal}
|
${dataHorizontal}
|
||||||
${dataMousewheel}
|
${dataMousewheel}
|
||||||
${dataCenterfocus}
|
${dataCenterfocus}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
is="emby-itemscontainer"
|
is="emby-itemscontainer"
|
||||||
${id}
|
class="${className}"
|
||||||
class="${className}"
|
>
|
||||||
>
|
</div>
|
||||||
</div>
|
|
||||||
</div>`
|
</div>`
|
||||||
});
|
});
|
||||||
|
|
||||||
type IProps = {
|
interface IProps {
|
||||||
scrollerclassName?: string;
|
scrollerclassName?: string;
|
||||||
dataHorizontal?: string;
|
dataHorizontal?: string;
|
||||||
dataMousewheel?: string;
|
dataMousewheel?: string;
|
||||||
dataCenterfocus?: string;
|
dataCenterfocus?: string;
|
||||||
id?: string;
|
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ItemsScrollerContainerElement: FunctionComponent<IProps> = ({ scrollerclassName, dataHorizontal, dataMousewheel, dataCenterfocus, id, className }: IProps) => {
|
const ItemsScrollerContainerElement: FC<IProps> = ({ scrollerclassName, dataHorizontal, dataMousewheel, dataCenterfocus, className }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
dangerouslySetInnerHTML={createScroller({
|
dangerouslySetInnerHTML={createScroller({
|
||||||
|
@ -33,7 +31,6 @@ const ItemsScrollerContainerElement: FunctionComponent<IProps> = ({ scrollerclas
|
||||||
dataHorizontal: dataHorizontal ? `data-horizontal="${dataHorizontal}"` : '',
|
dataHorizontal: dataHorizontal ? `data-horizontal="${dataHorizontal}"` : '',
|
||||||
dataMousewheel: dataMousewheel ? `data-mousewheel="${dataMousewheel}"` : '',
|
dataMousewheel: dataMousewheel ? `data-mousewheel="${dataMousewheel}"` : '',
|
||||||
dataCenterfocus: dataCenterfocus ? `data-centerfocus="${dataCenterfocus}"` : '',
|
dataCenterfocus: dataCenterfocus ? `data-centerfocus="${dataCenterfocus}"` : '',
|
||||||
id: id ? `id='${id}'` : '',
|
|
||||||
className: className
|
className: className
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
import '../elements/emby-tabs/emby-tabs';
|
import '../elements/emby-tabs/emby-tabs';
|
||||||
import '../elements/emby-button/emby-button';
|
import '../elements/emby-button/emby-button';
|
||||||
|
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useRef, useState } from 'react';
|
import React, { FC, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
import * as mainTabsManager from '../components/maintabsmanager';
|
import * as mainTabsManager from '../components/maintabsmanager';
|
||||||
|
@ -37,28 +37,28 @@ const getDefaultTabIndex = (folderId: string | null) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const Movies: FunctionComponent = () => {
|
const getTabs = () => {
|
||||||
|
return [{
|
||||||
|
name: globalize.translate('Movies')
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('Suggestions')
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('Trailers')
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('Favorites')
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('Collections')
|
||||||
|
}, {
|
||||||
|
name: globalize.translate('Genres')
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
|
||||||
|
const Movies: FC = () => {
|
||||||
const [ searchParams ] = useSearchParams();
|
const [ searchParams ] = useSearchParams();
|
||||||
const currentTabIndex = parseInt(searchParams.get('tab') || getDefaultTabIndex(searchParams.get('topParentId')).toString());
|
const currentTabIndex = parseInt(searchParams.get('tab') || getDefaultTabIndex(searchParams.get('topParentId')).toString());
|
||||||
const [ selectedIndex, setSelectedIndex ] = useState(currentTabIndex);
|
const [ selectedIndex, setSelectedIndex ] = useState(currentTabIndex);
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const getTabs = () => {
|
|
||||||
return [{
|
|
||||||
name: globalize.translate('Movies')
|
|
||||||
}, {
|
|
||||||
name: globalize.translate('Suggestions')
|
|
||||||
}, {
|
|
||||||
name: globalize.translate('Trailers')
|
|
||||||
}, {
|
|
||||||
name: globalize.translate('Favorites')
|
|
||||||
}, {
|
|
||||||
name: globalize.translate('Collections')
|
|
||||||
}, {
|
|
||||||
name: globalize.translate('Genres')
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
|
|
||||||
const getTabComponent = (index: number) => {
|
const getTabComponent = (index: number) => {
|
||||||
if (index == null) {
|
if (index == null) {
|
||||||
throw new Error('index cannot be null');
|
throw new Error('index cannot be null');
|
||||||
|
@ -106,7 +106,7 @@ const Movies: FunctionComponent = () => {
|
||||||
console.error('Unexpected null reference');
|
console.error('Unexpected null reference');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mainTabsManager.setTabs(element.current, selectedIndex, getTabs, undefined, undefined, onTabChange);
|
mainTabsManager.setTabs(page, selectedIndex, getTabs, undefined, undefined, onTabChange);
|
||||||
if (!page.getAttribute('data-title')) {
|
if (!page.getAttribute('data-title')) {
|
||||||
const parentId = searchParams.get('topParentId');
|
const parentId = searchParams.get('topParentId');
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useRef } from 'react';
|
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
||||||
import { Events } from 'jellyfin-apiclient';
|
import { Events } from 'jellyfin-apiclient';
|
||||||
import IconButtonElement from '../../elements/IconButtonElement';
|
import IconButtonElement from '../../elements/IconButtonElement';
|
||||||
import { IQuery } from './type';
|
import { QueryI } from './interface';
|
||||||
|
|
||||||
type FilterProps = {
|
interface FilterI {
|
||||||
query: IQuery;
|
query: QueryI;
|
||||||
getFilterMode: () => string | null;
|
getFilterMode: () => string | null;
|
||||||
reloadItems: () => void;
|
reloadItems: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Filter: FunctionComponent<FilterProps> = ({ query, getFilterMode, reloadItems }: FilterProps) => {
|
const Filter: FC<FilterI> = ({ query, getFilterMode, reloadItems }) => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const showFilterMenu = useCallback(() => {
|
const showFilterMenu = useCallback(() => {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
|
|
||||||
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import escapeHTML from 'escape-html';
|
import escapeHTML from 'escape-html';
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useRef } from 'react';
|
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import { appRouter } from '../../components/appRouter';
|
import { appRouter } from '../../components/appRouter';
|
||||||
import cardBuilder from '../../components/cardbuilder/cardBuilder';
|
import cardBuilder from '../../components/cardbuilder/cardBuilder';
|
||||||
|
@ -11,13 +11,13 @@ import layoutManager from '../../components/layoutManager';
|
||||||
import lazyLoader from '../../components/lazyLoader/lazyLoaderIntersectionObserver';
|
import lazyLoader from '../../components/lazyLoader/lazyLoaderIntersectionObserver';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
|
|
||||||
type GenresItemsContainerProps = {
|
interface GenresItemsContainerI {
|
||||||
topParentId?: string | null;
|
topParentId?: string | null;
|
||||||
getCurrentViewStyle: () => string;
|
getCurrentViewStyle: () => string;
|
||||||
itemsResult?: BaseItemDtoQueryResult;
|
itemsResult?: BaseItemDtoQueryResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GenresItemsContainer: FunctionComponent<GenresItemsContainerProps> = ({ topParentId, getCurrentViewStyle, itemsResult = {} }: GenresItemsContainerProps) => {
|
const GenresItemsContainer: FC<GenresItemsContainerI> = ({ topParentId, getCurrentViewStyle, itemsResult = {} }) => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const enableScrollX = useCallback(() => {
|
const enableScrollX = useCallback(() => {
|
||||||
|
|
|
@ -7,11 +7,11 @@ import listview from '../../components/listview/listview';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
import imageLoader from '../../components/images/imageLoader';
|
import imageLoader from '../../components/images/imageLoader';
|
||||||
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
import { IQuery } from './type';
|
import { QueryI } from './interface';
|
||||||
|
|
||||||
type ItemsContainerProps = {
|
type ItemsContainerProps = {
|
||||||
getCurrentViewStyle: () => string;
|
getCurrentViewStyle: () => string;
|
||||||
query: IQuery;
|
query: QueryI;
|
||||||
getContext: () => string | null;
|
getContext: () => string | null;
|
||||||
items?: BaseItemDto[] | null;
|
items?: BaseItemDto[] | null;
|
||||||
noItemsMessage?: string;
|
noItemsMessage?: string;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useRef } from 'react';
|
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import IconButtonElement from '../../elements/IconButtonElement';
|
import IconButtonElement from '../../elements/IconButtonElement';
|
||||||
|
|
||||||
const NewCollection: FunctionComponent = () => {
|
const NewCollection: FC = () => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const showCollectionEditor = useCallback(() => {
|
const showCollectionEditor = useCallback(() => {
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useRef } from 'react';
|
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
||||||
import IconButtonElement from '../../elements/IconButtonElement';
|
import IconButtonElement from '../../elements/IconButtonElement';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
import { IQuery } from './type';
|
import { QueryI } from './interface';
|
||||||
|
|
||||||
type PaginationProps = {
|
interface PaginationI {
|
||||||
query: IQuery;
|
query: QueryI;
|
||||||
itemsResult?: BaseItemDtoQueryResult;
|
itemsResult?: BaseItemDtoQueryResult;
|
||||||
reloadItems: () => void;
|
reloadItems: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Pagination: FunctionComponent<PaginationProps> = ({ query, itemsResult = {}, reloadItems }: PaginationProps) => {
|
const Pagination: FC<PaginationI> = ({ query, itemsResult = {}, reloadItems }) => {
|
||||||
const startIndex = query.StartIndex;
|
const startIndex = query.StartIndex;
|
||||||
const limit = query.Limit;
|
const limit = query.Limit;
|
||||||
const totalRecordCount = itemsResult.TotalRecordCount || 0;
|
const totalRecordCount = itemsResult.TotalRecordCount || 0;
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { RecommendationDto } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { RecommendationDto } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent } from 'react';
|
import React, { FC } from 'react';
|
||||||
|
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
import escapeHTML from 'escape-html';
|
import escapeHTML from 'escape-html';
|
||||||
import SectionContainer from './SectionContainer';
|
import SectionContainer from './SectionContainer';
|
||||||
|
|
||||||
type RecommendationContainerProps = {
|
interface RecommendationContainerI {
|
||||||
getPortraitShape: () => string;
|
getPortraitShape: () => string;
|
||||||
enableScrollX: () => boolean;
|
enableScrollX: () => boolean;
|
||||||
recommendation?: RecommendationDto;
|
recommendation?: RecommendationDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
const RecommendationContainer: FunctionComponent<RecommendationContainerProps> = ({ getPortraitShape, enableScrollX, recommendation = {} }: RecommendationContainerProps) => {
|
const RecommendationContainer: FC<RecommendationContainerI> = ({ getPortraitShape, enableScrollX, recommendation = {} }) => {
|
||||||
let title = '';
|
let title = '';
|
||||||
|
|
||||||
switch (recommendation.RecommendationType) {
|
switch (recommendation.RecommendationType) {
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
import '../../elements/emby-itemscontainer/emby-itemscontainer';
|
||||||
|
|
||||||
import { BaseItemDto } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { BaseItemDto } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import cardBuilder from '../../components/cardbuilder/cardBuilder';
|
import cardBuilder from '../../components/cardbuilder/cardBuilder';
|
||||||
import ItemsContainerElement from '../../elements/ItemsContainerElement';
|
import ItemsContainerElement from '../../elements/ItemsContainerElement';
|
||||||
import ItemsScrollerContainerElement from '../../elements/ItemsScrollerContainerElement';
|
import ItemsScrollerContainerElement from '../../elements/ItemsScrollerContainerElement';
|
||||||
import { ICardOptions } from './type';
|
import { CardOptionsI } from './interface';
|
||||||
|
|
||||||
type SectionContainerProps = {
|
interface SectionContainerI {
|
||||||
sectionTitle: string;
|
sectionTitle: string;
|
||||||
enableScrollX: () => boolean;
|
enableScrollX: () => boolean;
|
||||||
items?: BaseItemDto[];
|
items?: BaseItemDto[];
|
||||||
cardOptions?: ICardOptions;
|
cardOptions?: CardOptionsI;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SectionContainer: FunctionComponent<SectionContainerProps> = ({
|
const SectionContainer: FC<SectionContainerI> = ({
|
||||||
sectionTitle,
|
sectionTitle,
|
||||||
enableScrollX,
|
enableScrollX,
|
||||||
items = [],
|
items = [],
|
||||||
cardOptions = {}
|
cardOptions = {}
|
||||||
}: SectionContainerProps) => {
|
}) => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
import IconButtonElement from '../../elements/IconButtonElement';
|
import IconButtonElement from '../../elements/IconButtonElement';
|
||||||
|
|
||||||
import libraryBrowser from '../../scripts/libraryBrowser';
|
import libraryBrowser from '../../scripts/libraryBrowser';
|
||||||
import * as userSettings from '../../scripts/settings/userSettings';
|
import * as userSettings from '../../scripts/settings/userSettings';
|
||||||
import { IQuery } from './type';
|
import { QueryI } from './interface';
|
||||||
|
|
||||||
type SelectViewProps = {
|
interface SelectViewI {
|
||||||
getCurrentViewStyle: () => string;
|
getCurrentViewStyle: () => string;
|
||||||
query: IQuery;
|
query: QueryI;
|
||||||
getViewSettings: () => string;
|
getViewSettings: () => string;
|
||||||
reloadItems: () => void;
|
reloadItems: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SelectView: FunctionComponent<SelectViewProps> = ({ getCurrentViewStyle, getViewSettings, query, reloadItems }: SelectViewProps) => {
|
const SelectView: FC<SelectViewI> = ({ getCurrentViewStyle, getViewSettings, query, reloadItems }) => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useRef } from 'react';
|
import React, { FC, useCallback, useEffect, useRef } from 'react';
|
||||||
|
|
||||||
import { playbackManager } from '../../components/playback/playbackmanager';
|
import { playbackManager } from '../../components/playback/playbackmanager';
|
||||||
import IconButtonElement from '../../elements/IconButtonElement';
|
import IconButtonElement from '../../elements/IconButtonElement';
|
||||||
|
|
||||||
type ShuffleProps = {
|
interface ShuffleI {
|
||||||
itemsResult?: BaseItemDtoQueryResult;
|
itemsResult?: BaseItemDtoQueryResult;
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Shuffle: FunctionComponent<ShuffleProps> = ({ itemsResult = {}, topParentId }: ShuffleProps) => {
|
const Shuffle: FC<ShuffleI> = ({ itemsResult = {}, topParentId }) => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const shuffle = useCallback(() => {
|
const shuffle = useCallback(() => {
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
import IconButtonElement from '../../elements/IconButtonElement';
|
import IconButtonElement from '../../elements/IconButtonElement';
|
||||||
import libraryBrowser from '../../scripts/libraryBrowser';
|
import libraryBrowser from '../../scripts/libraryBrowser';
|
||||||
import * as userSettings from '../../scripts/settings/userSettings';
|
import * as userSettings from '../../scripts/settings/userSettings';
|
||||||
import { IQuery } from './type';
|
import { QueryI } from './interface';
|
||||||
|
|
||||||
type SortProps = {
|
interface SortI {
|
||||||
getSortMenuOptions: () => {
|
getSortMenuOptions: () => {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
}[];
|
}[];
|
||||||
query: IQuery;
|
query: QueryI;
|
||||||
getSettingsKey: () => string;
|
getSettingsKey: () => string;
|
||||||
reloadItems: () => void;
|
reloadItems: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Sort: FunctionComponent<SortProps> = ({ getSortMenuOptions, query, getSettingsKey, reloadItems }: SortProps) => {
|
const Sort: FC<SortI> = ({ getSortMenuOptions, query, getSettingsKey, reloadItems }) => {
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
import loading from '../../components/loading/loading';
|
import loading from '../../components/loading/loading';
|
||||||
import * as userSettings from '../../scripts/settings/userSettings';
|
import * as userSettings from '../../scripts/settings/userSettings';
|
||||||
|
@ -10,10 +10,10 @@ import Pagination from './Pagination';
|
||||||
import SelectView from './SelectView';
|
import SelectView from './SelectView';
|
||||||
import Shuffle from './Shuffle';
|
import Shuffle from './Shuffle';
|
||||||
import Sort from './Sort';
|
import Sort from './Sort';
|
||||||
import { IQuery } from './type';
|
import { QueryI } from './interface';
|
||||||
import NewCollection from './NewCollection';
|
import NewCollection from './NewCollection';
|
||||||
|
|
||||||
type IProps = {
|
interface ViewItemsContainerI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
isBtnShuffleEnabled?: boolean;
|
isBtnShuffleEnabled?: boolean;
|
||||||
isBtnFilterEnabled?: boolean;
|
isBtnFilterEnabled?: boolean;
|
||||||
|
@ -29,7 +29,7 @@ type IProps = {
|
||||||
getNoItemsMessage: () => string;
|
getNoItemsMessage: () => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViewItemsContainer: FunctionComponent<IProps> = ({
|
const ViewItemsContainer: FC<ViewItemsContainerI> = ({
|
||||||
topParentId,
|
topParentId,
|
||||||
isBtnShuffleEnabled = false,
|
isBtnShuffleEnabled = false,
|
||||||
isBtnFilterEnabled = true,
|
isBtnFilterEnabled = true,
|
||||||
|
@ -40,7 +40,7 @@ const ViewItemsContainer: FunctionComponent<IProps> = ({
|
||||||
getItemTypes,
|
getItemTypes,
|
||||||
getSortMenuOptions,
|
getSortMenuOptions,
|
||||||
getNoItemsMessage
|
getNoItemsMessage
|
||||||
}: IProps) => {
|
}) => {
|
||||||
const [ itemsResult, setItemsResult ] = useState<BaseItemDtoQueryResult>({});
|
const [ itemsResult, setItemsResult ] = useState<BaseItemDtoQueryResult>({});
|
||||||
|
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
@ -53,7 +53,7 @@ const ViewItemsContainer: FunctionComponent<IProps> = ({
|
||||||
return `${getSettingsKey()} -view`;
|
return `${getSettingsKey()} -view`;
|
||||||
}, [getSettingsKey]);
|
}, [getSettingsKey]);
|
||||||
|
|
||||||
let query = useMemo<IQuery>(() => ({
|
let query = useMemo<QueryI>(() => ({
|
||||||
SortBy: 'SortName,ProductionYear',
|
SortBy: 'SortName,ProductionYear',
|
||||||
SortOrder: 'Ascending',
|
SortOrder: 'Ascending',
|
||||||
IncludeItemTypes: getItemTypes(),
|
IncludeItemTypes: getItemTypes(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export type IQuery = {
|
export type QueryI = {
|
||||||
SortBy?: string;
|
SortBy?: string;
|
||||||
SortOrder?: string;
|
SortOrder?: string;
|
||||||
IncludeItemTypes?: string;
|
IncludeItemTypes?: string;
|
||||||
|
@ -16,7 +16,7 @@ export type IQuery = {
|
||||||
NameStartsWith?: string;
|
NameStartsWith?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ICardOptions = {
|
export type CardOptionsI = {
|
||||||
itemsContainer?: HTMLElement;
|
itemsContainer?: HTMLElement;
|
||||||
parentContainer?: HTMLElement;
|
parentContainer?: HTMLElement;
|
||||||
allowBottomPadding?: boolean;
|
allowBottomPadding?: boolean;
|
|
@ -1,13 +1,13 @@
|
||||||
import React, { FunctionComponent, useCallback } from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
|
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
import ViewItemsContainer from '../components/ViewItemsContainer';
|
import ViewItemsContainer from '../components/ViewItemsContainer';
|
||||||
|
|
||||||
type IProps = {
|
interface CollectionsViewI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CollectionsView: FunctionComponent<IProps> = ({ topParentId }: IProps) => {
|
const CollectionsView: FC<CollectionsViewI> = ({ topParentId }) => {
|
||||||
const getBasekey = useCallback(() => {
|
const getBasekey = useCallback(() => {
|
||||||
return 'collections';
|
return 'collections';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import React, { FunctionComponent, useCallback } from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
|
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
import ViewItemsContainer from '../components/ViewItemsContainer';
|
import ViewItemsContainer from '../components/ViewItemsContainer';
|
||||||
|
|
||||||
type IProps = {
|
interface FavoritesViewI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const FavoritesView: FunctionComponent<IProps> = ({ topParentId }: IProps) => {
|
const FavoritesView: FC<FavoritesViewI> = ({ topParentId }) => {
|
||||||
const getBasekey = useCallback(() => {
|
const getBasekey = useCallback(() => {
|
||||||
return 'favorites';
|
return 'favorites';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
import { BaseItemDtoQueryResult } from '@thornbill/jellyfin-sdk/dist/generated-client';
|
||||||
import React, { FunctionComponent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
|
|
||||||
import loading from '../../components/loading/loading';
|
import loading from '../../components/loading/loading';
|
||||||
import * as userSettings from '../../scripts/settings/userSettings';
|
import * as userSettings from '../../scripts/settings/userSettings';
|
||||||
import GenresItemsContainer from '../components/GenresItemsContainer';
|
import GenresItemsContainer from '../components/GenresItemsContainer';
|
||||||
import { IQuery } from '../components/type';
|
import { QueryI } from '../components/interface';
|
||||||
|
|
||||||
type IProps = {
|
interface GenresViewI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GenresView: FunctionComponent<IProps> = ({ topParentId }: IProps) => {
|
const GenresView: FC<GenresViewI> = ({ topParentId }) => {
|
||||||
const [ itemsResult, setItemsResult ] = useState<BaseItemDtoQueryResult>({});
|
const [ itemsResult, setItemsResult ] = useState<BaseItemDtoQueryResult>({});
|
||||||
const element = useRef<HTMLDivElement>(null);
|
const element = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ const GenresView: FunctionComponent<IProps> = ({ topParentId }: IProps) => {
|
||||||
return getSettingsKey() + '-view';
|
return getSettingsKey() + '-view';
|
||||||
}, [getSettingsKey]);
|
}, [getSettingsKey]);
|
||||||
|
|
||||||
let query = useMemo<IQuery>(() => ({
|
let query = useMemo<QueryI>(() => ({
|
||||||
SortBy: 'SortName',
|
SortBy: 'SortName',
|
||||||
SortOrder: 'Ascending',
|
SortOrder: 'Ascending',
|
||||||
IncludeItemTypes: 'Movie',
|
IncludeItemTypes: 'Movie',
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import React, { FunctionComponent, useCallback } from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
|
|
||||||
import ViewItemsContainer from '../components/ViewItemsContainer';
|
import ViewItemsContainer from '../components/ViewItemsContainer';
|
||||||
|
|
||||||
type IProps = {
|
interface MoviesViewI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MoviesView: FunctionComponent<IProps> = ({ topParentId }: IProps) => {
|
const MoviesView: FC<MoviesViewI> = ({ topParentId }) => {
|
||||||
const getBasekey = useCallback(() => {
|
const getBasekey = useCallback(() => {
|
||||||
return 'movies';
|
return 'movies';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
@ -8,11 +8,11 @@ import globalize from '../../scripts/globalize';
|
||||||
import RecommendationContainer from '../components/RecommendationContainer';
|
import RecommendationContainer from '../components/RecommendationContainer';
|
||||||
import SectionContainer from '../components/SectionContainer';
|
import SectionContainer from '../components/SectionContainer';
|
||||||
|
|
||||||
type IProps = {
|
interface SuggestionsViewI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SuggestionsView: FunctionComponent<IProps> = (props: IProps) => {
|
const SuggestionsView: FunctionComponent<SuggestionsViewI> = ({topParentId}) => {
|
||||||
const [ latestItems, setLatestItems ] = useState<BaseItemDto[]>([]);
|
const [ latestItems, setLatestItems ] = useState<BaseItemDto[]>([]);
|
||||||
const [ resumeResult, setResumeResult ] = useState<BaseItemDtoQueryResult>({});
|
const [ resumeResult, setResumeResult ] = useState<BaseItemDtoQueryResult>({});
|
||||||
const [ recommendations, setRecommendations ] = useState<RecommendationDto[]>([]);
|
const [ recommendations, setRecommendations ] = useState<RecommendationDto[]>([]);
|
||||||
|
@ -102,12 +102,12 @@ const SuggestionsView: FunctionComponent<IProps> = (props: IProps) => {
|
||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
const loadSuggestionsTab = useCallback((view) => {
|
const loadSuggestionsTab = useCallback((view) => {
|
||||||
const parentId = props.topParentId;
|
const parentId = topParentId;
|
||||||
const userId = window.ApiClient.getCurrentUserId();
|
const userId = window.ApiClient.getCurrentUserId();
|
||||||
loadResume(view, userId, parentId);
|
loadResume(view, userId, parentId);
|
||||||
loadLatest(view, userId, parentId);
|
loadLatest(view, userId, parentId);
|
||||||
loadSuggestions(view, userId);
|
loadSuggestions(view, userId);
|
||||||
}, [loadLatest, loadResume, loadSuggestions, props.topParentId]);
|
}, [loadLatest, loadResume, loadSuggestions, topParentId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const page = element.current;
|
const page = element.current;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
|
||||||
import React, { FunctionComponent, useCallback } from 'react';
|
import React, { FC, useCallback } from 'react';
|
||||||
|
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
import ViewItemsContainer from '../components/ViewItemsContainer';
|
import ViewItemsContainer from '../components/ViewItemsContainer';
|
||||||
|
|
||||||
type IProps = {
|
interface TrailersViewI {
|
||||||
topParentId: string | null;
|
topParentId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TrailersView: FunctionComponent<IProps> = ({ topParentId }: IProps) => {
|
const TrailersView: FC<TrailersViewI> = ({ topParentId }) => {
|
||||||
const getBasekey = useCallback(() => {
|
const getBasekey = useCallback(() => {
|
||||||
return 'trailers';
|
return 'trailers';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue