diff --git a/src/apps/experimental/components/library/GenresSectionContainer.tsx b/src/apps/experimental/components/library/GenresSectionContainer.tsx index 39e81052eb..0cef257a88 100644 --- a/src/apps/experimental/components/library/GenresSectionContainer.tsx +++ b/src/apps/experimental/components/library/GenresSectionContainer.tsx @@ -1,4 +1,3 @@ -import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client'; import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type'; import { ItemFields } from '@jellyfin/sdk/lib/generated-client/models/item-fields'; import { ImageType } from '@jellyfin/sdk/lib/generated-client/models/image-type'; @@ -12,12 +11,13 @@ import { appRouter } from 'components/router/appRouter'; import SectionContainer from './SectionContainer'; import { CardShape } from 'utils/card'; import type { ParentId } from 'types/library'; +import type { ItemDto } from 'types/base/models/item-dto'; interface GenresSectionContainerProps { parentId: ParentId; collectionType: CollectionType | undefined; itemType: BaseItemKind[]; - genre: BaseItemDto; + genre: ItemDto; } const GenresSectionContainer: FC = ({ @@ -47,7 +47,7 @@ const GenresSectionContainer: FC = ({ const { isLoading, data: itemsResult } = useGetItems(getParametersOptions()); - const getRouteUrl = (item: BaseItemDto) => { + const getRouteUrl = (item: ItemDto) => { return appRouter.getRouteUrl(item, { context: collectionType, parentId: parentId diff --git a/src/apps/experimental/components/library/PlayAllButton.tsx b/src/apps/experimental/components/library/PlayAllButton.tsx index 45eb1db8f2..65315d2168 100644 --- a/src/apps/experimental/components/library/PlayAllButton.tsx +++ b/src/apps/experimental/components/library/PlayAllButton.tsx @@ -1,4 +1,3 @@ -import type { BaseItemDto, SeriesTimerInfoDto } from '@jellyfin/sdk/lib/generated-client'; import React, { FC, useCallback } from 'react'; import { IconButton } from '@mui/material'; import PlayArrowIcon from '@mui/icons-material/PlayArrow'; @@ -8,10 +7,11 @@ import globalize from 'lib/globalize'; import { getFiltersQuery } from 'utils/items'; import { LibraryViewSettings } from 'types/library'; import { LibraryTab } from 'types/libraryTab'; +import type { ItemDto } from 'types/base/models/item-dto'; interface PlayAllButtonProps { - item: BaseItemDto | null | undefined; - items: BaseItemDto[] | SeriesTimerInfoDto[]; + item: ItemDto | undefined; + items: ItemDto[]; viewType: LibraryTab; hasFilters: boolean; libraryViewSettings: LibraryViewSettings diff --git a/src/apps/experimental/components/library/QueueButton.tsx b/src/apps/experimental/components/library/QueueButton.tsx index d0e93df489..3b9cca64c3 100644 --- a/src/apps/experimental/components/library/QueueButton.tsx +++ b/src/apps/experimental/components/library/QueueButton.tsx @@ -1,14 +1,14 @@ -import type { BaseItemDto, SeriesTimerInfoDto } from '@jellyfin/sdk/lib/generated-client'; import React, { FC, useCallback } from 'react'; import { IconButton } from '@mui/material'; import QueueIcon from '@mui/icons-material/Queue'; import { playbackManager } from 'components/playback/playbackmanager'; import globalize from 'lib/globalize'; +import type { ItemDto } from 'types/base/models/item-dto'; interface QueueButtonProps { - item: BaseItemDto | undefined - items: BaseItemDto[] | SeriesTimerInfoDto[]; + item: ItemDto | undefined + items: ItemDto[]; hasFilters: boolean; } diff --git a/src/apps/experimental/components/library/SectionContainer.tsx b/src/apps/experimental/components/library/SectionContainer.tsx index 8eb64c4e6f..e2351cac4e 100644 --- a/src/apps/experimental/components/library/SectionContainer.tsx +++ b/src/apps/experimental/components/library/SectionContainer.tsx @@ -1,4 +1,3 @@ -import type { BaseItemDto, TimerInfoDto } from '@jellyfin/sdk/lib/generated-client'; import React, { FC } from 'react'; import ItemsContainer from 'elements/emby-itemscontainer/ItemsContainer'; @@ -6,11 +5,12 @@ import Scroller from 'elements/emby-scroller/Scroller'; import LinkButton from 'elements/emby-button/LinkButton'; import Cards from 'components/cardbuilder/Card/Cards'; import type { CardOptions } from 'types/cardOptions'; +import type { ItemDto } from 'types/base/models/item-dto'; interface SectionContainerProps { url?: string; sectionTitle: string; - items: BaseItemDto[] | TimerInfoDto[]; + items: ItemDto[]; cardOptions: CardOptions; reloadItems?: () => void; } diff --git a/src/apps/experimental/components/library/ShuffleButton.tsx b/src/apps/experimental/components/library/ShuffleButton.tsx index ec75caeffd..dde6d56417 100644 --- a/src/apps/experimental/components/library/ShuffleButton.tsx +++ b/src/apps/experimental/components/library/ShuffleButton.tsx @@ -1,4 +1,3 @@ -import type { BaseItemDto, SeriesTimerInfoDto } from '@jellyfin/sdk/lib/generated-client'; import { ItemSortBy } from '@jellyfin/sdk/lib/models/api/item-sort-by'; import React, { FC, useCallback } from 'react'; import { IconButton } from '@mui/material'; @@ -9,10 +8,11 @@ import globalize from 'lib/globalize'; import { getFiltersQuery } from 'utils/items'; import { LibraryViewSettings } from 'types/library'; import { LibraryTab } from 'types/libraryTab'; +import type { ItemDto } from 'types/base/models/item-dto'; interface ShuffleButtonProps { - item: BaseItemDto | null | undefined; - items: BaseItemDto[] | SeriesTimerInfoDto[]; + item: ItemDto | undefined; + items: ItemDto[]; viewType: LibraryTab hasFilters: boolean; libraryViewSettings: LibraryViewSettings diff --git a/src/apps/experimental/components/library/SuggestionsSectionView.tsx b/src/apps/experimental/components/library/SuggestionsSectionView.tsx index 26602e5a83..9dc480e98c 100644 --- a/src/apps/experimental/components/library/SuggestionsSectionView.tsx +++ b/src/apps/experimental/components/library/SuggestionsSectionView.tsx @@ -1,7 +1,5 @@ -import { - type RecommendationDto, - RecommendationType -} from '@jellyfin/sdk/lib/generated-client'; +import type { RecommendationDto } from '@jellyfin/sdk/lib/generated-client/models/recommendation-dto'; +import { RecommendationType } from '@jellyfin/sdk/lib/generated-client/models/recommendation-type'; import React, { type FC } from 'react'; import { useGetMovieRecommendations, @@ -14,6 +12,7 @@ import SectionContainer from './SectionContainer'; import { CardShape } from 'utils/card'; import type { ParentId } from 'types/library'; import type { Section, SectionType } from 'types/sections'; +import type { ItemDto } from 'types/base/models/item-dto'; interface SuggestionsSectionViewProps { parentId: ParentId; @@ -116,7 +115,7 @@ const SuggestionsSectionView: FC = ({ // eslint-disable-next-line react/no-array-index-key key={`${recommendation.CategoryId}-${index}`} // use a unique id return value may have duplicate id sectionTitle={getRecommendationTittle(recommendation)} - items={recommendation.Items ?? []} + items={(recommendation.Items as ItemDto[]) ?? []} cardOptions={{ queryKey: ['MovieRecommendations'], shape: CardShape.PortraitOverflow, diff --git a/src/components/cardbuilder/Card/CardBox.tsx b/src/components/cardbuilder/Card/CardBox.tsx index a7fd41c0cd..4fe47b0e01 100644 --- a/src/components/cardbuilder/Card/CardBox.tsx +++ b/src/components/cardbuilder/Card/CardBox.tsx @@ -6,6 +6,7 @@ import CardHoverMenu from './CardHoverMenu'; import CardOuterFooter from './CardOuterFooter'; import CardContent from './CardContent'; import { CardShape } from 'utils/card'; + import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; diff --git a/src/components/cardbuilder/Card/CardFooterText.tsx b/src/components/cardbuilder/Card/CardFooterText.tsx index 934aa5c8a7..6aa66ef2e7 100644 --- a/src/components/cardbuilder/Card/CardFooterText.tsx +++ b/src/components/cardbuilder/Card/CardFooterText.tsx @@ -2,10 +2,11 @@ import React, { type FC } from 'react'; import Box from '@mui/material/Box'; import useCardText from './useCardText'; import layoutManager from 'components/layoutManager'; -import MoreVertIconButton from '../../common/MoreVertIconButton'; +import MoreVertIconButton from 'components/common/MoreVertIconButton'; +import Image from 'components/common/Image'; + import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; -import Image from 'components/common/Image'; const shouldShowDetailsMenu = ( cardOptions: CardOptions, diff --git a/src/components/cardbuilder/Card/CardImageContainer.tsx b/src/components/cardbuilder/Card/CardImageContainer.tsx index c6c7f2915c..8701329854 100644 --- a/src/components/cardbuilder/Card/CardImageContainer.tsx +++ b/src/components/cardbuilder/Card/CardImageContainer.tsx @@ -1,4 +1,3 @@ -import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import React, { type FC } from 'react'; import Box from '@mui/material/Box'; import classNames from 'classnames'; @@ -7,6 +6,7 @@ import RefreshIndicator from 'elements/emby-itemrefreshindicator/RefreshIndicato import Media from '../../common/Media'; import CardInnerFooter from './CardInnerFooter'; +import { ItemKind } from 'types/base/models/item-kind'; import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; @@ -33,7 +33,7 @@ const CardImageContainer: FC = ({ const cardImageClass = classNames( 'cardImageContainer', { coveredImage: coveredImage }, - { 'coveredImage-contain': coveredImage && item.Type === BaseItemKind.TvChannel } + { 'coveredImage-contain': coveredImage && item.Type === ItemKind.TvChannel } ); return ( @@ -53,7 +53,7 @@ const CardImageContainer: FC = ({ indicator.getChildCountIndicator() : indicator.getPlayedIndicator()} - {(item.Type === BaseItemKind.CollectionFolder + {(item.Type === ItemKind.CollectionFolder || item.CollectionType) && ( )} diff --git a/src/components/cardbuilder/Card/CardInnerFooter.tsx b/src/components/cardbuilder/Card/CardInnerFooter.tsx index e5908adc27..8b018ecc78 100644 --- a/src/components/cardbuilder/Card/CardInnerFooter.tsx +++ b/src/components/cardbuilder/Card/CardInnerFooter.tsx @@ -1,6 +1,7 @@ import React, { type FC } from 'react'; import classNames from 'classnames'; import CardFooterText from './CardFooterText'; + import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; diff --git a/src/components/cardbuilder/Card/CardOverlayButtons.tsx b/src/components/cardbuilder/Card/CardOverlayButtons.tsx index a00b194587..5de5ea6ed3 100644 --- a/src/components/cardbuilder/Card/CardOverlayButtons.tsx +++ b/src/components/cardbuilder/Card/CardOverlayButtons.tsx @@ -1,4 +1,3 @@ -import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import { LocationType } from '@jellyfin/sdk/lib/generated-client/models/location-type'; import React, { type FC } from 'react'; import ButtonGroup from '@mui/material/ButtonGroup'; @@ -7,6 +6,8 @@ import { appRouter } from 'components/router/appRouter'; import PlayArrowIconButton from '../../common/PlayArrowIconButton'; import MoreVertIconButton from '../../common/MoreVertIconButton'; +import { ItemKind } from 'types/base/models/item-kind'; +import { ItemMediaKind } from 'types/base/models/item-media-kind'; import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; @@ -19,8 +20,8 @@ const sholudShowOverlayPlayButton = ( && !item.IsPlaceHolder && (item.LocationType !== LocationType.Virtual || !item.MediaType - || item.Type === BaseItemKind.Program) - && item.Type !== BaseItemKind.Person + || item.Type === ItemKind.Program) + && item.Type !== ItemKind.Person ); }; @@ -41,7 +42,7 @@ const CardOverlayButtons: FC = ({ && !cardOptions.overlayInfoButton && !cardOptions.cardLayout ) { - overlayPlayButton = item.MediaType === 'Video'; + overlayPlayButton = item.MediaType === ItemMediaKind.Video; } const url = appRouter.getRouteUrl(item, { diff --git a/src/components/cardbuilder/Card/cardHelper.ts b/src/components/cardbuilder/Card/cardHelper.ts index e836abba3f..c7e7bc9280 100644 --- a/src/components/cardbuilder/Card/cardHelper.ts +++ b/src/components/cardbuilder/Card/cardHelper.ts @@ -1,10 +1,6 @@ -import { - BaseItemDto, - BaseItemKind, - BaseItemPerson, - ImageType -} from '@jellyfin/sdk/lib/generated-client'; import { Api } from '@jellyfin/sdk'; +import type { BaseItemPerson } from '@jellyfin/sdk/lib/generated-client/models/base-item-person'; +import { ImageType } from '@jellyfin/sdk/lib/generated-client/models/image-type'; import { getImageApi } from '@jellyfin/sdk/lib/utils/api/image-api'; import { appRouter } from 'components/router/appRouter'; @@ -12,14 +8,15 @@ import layoutManager from 'components/layoutManager'; import itemHelper from 'components/itemHelper'; import globalize from 'lib/globalize'; import datetime from 'scripts/datetime'; - import { isUsingLiveTvNaming } from '../cardBuilderUtils'; +import { getDataAttributes } from 'utils/items'; +import { ItemKind } from 'types/base/models/item-kind'; +import { ItemMediaKind } from 'types/base/models/item-media-kind'; import type { NullableNumber, NullableString } from 'types/base/common/shared/types'; import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; import type { DataAttributes } from 'types/dataAttributes'; -import { getDataAttributes } from 'utils/items'; export function getCardLogoUrl( item: ItemDto, @@ -142,15 +139,15 @@ export function getAirTimeText( return airTimeText; } -function isGenreOrStudio(itemType: NullableString) { - return itemType === BaseItemKind.Genre || itemType === BaseItemKind.Studio; +function isGenreOrStudio(itemType: ItemKind) { + return itemType === ItemKind.Genre || itemType === ItemKind.Studio; } function isMusicGenreOrMusicArtist( - itemType: NullableString, + itemType: ItemKind, context: NullableString ) { - return itemType === BaseItemKind.MusicGenre || context === 'MusicArtist'; + return itemType === ItemKind.MusicGenre || context === 'MusicArtist'; } function getMovieCount(itemMovieCount: NullableNumber) { @@ -213,8 +210,8 @@ function getParentTitle( item: ItemDto ) { if (isOuterFooter && item.AlbumArtists?.length) { - (item.AlbumArtists[0] as BaseItemDto).Type = BaseItemKind.MusicArtist; - (item.AlbumArtists[0] as BaseItemDto).IsFolder = true; + (item.AlbumArtists[0] as ItemDto).Type = ItemKind.MusicArtist; + (item.AlbumArtists[0] as ItemDto).IsFolder = true; return getTextActionButton(item.AlbumArtists[0], null, serverId); } else { return { @@ -250,7 +247,7 @@ export function getItemCounts(cardOptions: CardOptions, item: ItemDto) { } }; - if (item.Type === BaseItemKind.Playlist) { + if (item.Type === ItemKind.Playlist) { const runTimeTicksText = getRunTimeTicks(item.RunTimeTicks); addCount(runTimeTicksText); } else if (isGenreOrStudio(item.Type)) { @@ -271,7 +268,7 @@ export function getItemCounts(cardOptions: CardOptions, item: ItemDto) { const musicVideoCountText = getMusicVideoCount(item.MusicVideoCount); addCount(musicVideoCountText); - } else if (item.Type === BaseItemKind.Series) { + } else if (item.Type === ItemKind.Series) { const recursiveItemCountText = getRecursiveItemCount( item.RecursiveItemCount ); @@ -283,12 +280,12 @@ export function getItemCounts(cardOptions: CardOptions, item: ItemDto) { export function shouldShowTitle( showTitle: boolean | string | undefined, - itemType: NullableString + itemType: ItemKind ) { return ( Boolean(showTitle) - || itemType === BaseItemKind.PhotoAlbum - || itemType === BaseItemKind.Folder + || itemType === ItemKind.PhotoAlbum + || itemType === ItemKind.Folder ); } @@ -300,12 +297,12 @@ export function shouldShowOtherText( } export function shouldShowParentTitleUnderneath( - itemType: NullableString + itemType: ItemKind ) { return ( - itemType === BaseItemKind.MusicAlbum - || itemType === BaseItemKind.Audio - || itemType === BaseItemKind.MusicVideo + itemType === ItemKind.MusicAlbum + || itemType === ItemKind.Audio + || itemType === ItemKind.MusicVideo ); } @@ -338,16 +335,16 @@ function shouldShowSeriesYearOrYear( function shouldShowCurrentProgram( showCurrentProgram: boolean | undefined, - itemType: NullableString + itemType: ItemKind ) { - return showCurrentProgram && itemType === BaseItemKind.TvChannel; + return showCurrentProgram && itemType === ItemKind.TvChannel; } function shouldShowCurrentProgramTime( showCurrentProgramTime: boolean | undefined, - itemType: NullableString + itemType: ItemKind ) { - return showCurrentProgramTime && itemType === BaseItemKind.TvChannel; + return showCurrentProgramTime && itemType === ItemKind.TvChannel; } function shouldShowPersonRoleOrType( @@ -475,7 +472,7 @@ function getSeriesTimerTime(item: ItemDto) { } } -function getCurrentProgramTime(CurrentProgram: BaseItemDto | undefined) { +function getCurrentProgramTime(CurrentProgram: ItemDto | undefined) { if (CurrentProgram) { return getAirTimeText(CurrentProgram, false, true) || ''; } else { @@ -483,7 +480,7 @@ function getCurrentProgramTime(CurrentProgram: BaseItemDto | undefined) { } } -function getCurrentProgramName(CurrentProgram: BaseItemDto | undefined) { +function getCurrentProgramName(CurrentProgram: ItemDto | undefined) { if (CurrentProgram) { return CurrentProgram.Name; } else { @@ -498,7 +495,7 @@ function getChannelName(item: ItemDto) { Id: item.ChannelId, ServerId: item.ServerId, Name: item.ChannelName, - Type: BaseItemKind.TvChannel, + Type: ItemKind.TvChannel, MediaType: item.MediaType, IsFolder: false }, @@ -548,7 +545,7 @@ function getProductionYear(item: ItemDto) { && datetime.toLocaleString(item.ProductionYear, { useGrouping: false }); - if (item.Type === BaseItemKind.Series) { + if (item.Type === ItemKind.Series) { if (item.Status === 'Continuing') { return globalize.translate( 'SeriesYearToPresent', @@ -575,7 +572,7 @@ function getMediaTitle(cardOptions: CardOptions, item: ItemDto): TextLine { const name = cardOptions.showTitle === 'auto' && !item.IsFolder - && item.MediaType === 'Photo' ? + && item.MediaType === ItemMediaKind.Photo ? '' : itemHelper.getDisplayName(item, { includeParentInfo: cardOptions.includeParentInfoInTitle @@ -599,7 +596,7 @@ function getParentTitleOrTitle( ): TextLine { if ( isOuterFooter - && item.Type === BaseItemKind.Episode + && item.Type === ItemKind.Episode && item.SeriesName ) { if (item.SeriesId) { @@ -607,7 +604,7 @@ function getParentTitleOrTitle( Id: item.SeriesId, ServerId: item.ServerId, Name: item.SeriesName, - Type: BaseItemKind.Series, + Type: ItemKind.Series, IsFolder: true }); } else { diff --git a/src/components/cardbuilder/Card/useCard.ts b/src/components/cardbuilder/Card/useCard.ts index 6c031afa8d..d5bc82b893 100644 --- a/src/components/cardbuilder/Card/useCard.ts +++ b/src/components/cardbuilder/Card/useCard.ts @@ -1,4 +1,3 @@ -import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import classNames from 'classnames'; import useCardImageUrl from './useCardImageUrl'; import { @@ -9,6 +8,8 @@ import { getDataAttributes } from 'utils/items'; import { CardShape } from 'utils/card'; import layoutManager from 'components/layoutManager'; +import { ItemKind } from 'types/base/models/item-kind'; +import { ItemMediaKind } from 'types/base/models/item-media-kind'; import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; @@ -21,7 +22,7 @@ function useCard({ item, cardOptions }: UseCardProps) { const action = resolveAction({ defaultAction: cardOptions.action ?? 'link', isFolder: item.IsFolder ?? false, - isPhoto: item.MediaType === 'Photo' + isPhoto: item.MediaType === ItemMediaKind.Photo }); let shape = cardOptions.shape; @@ -84,9 +85,9 @@ function useCard({ item, cardOptions }: UseCardProps) { { groupedCard: cardOptions.showChildCountIndicator && item.ChildCount }, { 'card-withuserdata': - item.Type !== BaseItemKind.MusicAlbum - && item.Type !== BaseItemKind.MusicArtist - && item.Type !== BaseItemKind.Audio + item.Type !== ItemKind.MusicAlbum + && item.Type !== ItemKind.MusicArtist + && item.Type !== ItemKind.Audio }, { itemAction: layoutManager.tv } ); diff --git a/src/components/cardbuilder/Card/useCardImageUrl.ts b/src/components/cardbuilder/Card/useCardImageUrl.ts index fe1a91ae7f..4fe68fac53 100644 --- a/src/components/cardbuilder/Card/useCardImageUrl.ts +++ b/src/components/cardbuilder/Card/useCardImageUrl.ts @@ -1,9 +1,11 @@ -import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import { ImageType } from '@jellyfin/sdk/lib/generated-client/models/image-type'; import { getImageApi } from '@jellyfin/sdk/lib/utils/api/image-api'; import { useApi } from 'hooks/useApi'; import { getDesiredAspect } from '../cardBuilderUtils'; import { CardShape } from 'utils/card'; + +import { ItemKind } from 'types/base/models/item-kind'; +import { ItemMediaKind } from 'types/base/models/item-media-kind'; import type { NullableNumber, NullableString } from 'types/base/common/shared/types'; import type { ItemDto } from 'types/base/models/item-dto'; import type { CardOptions } from 'types/cardOptions'; @@ -25,7 +27,7 @@ function getPreferThumbInfo(item: ItemDto, cardOptions: CardOptions) { } else if ( item.ParentThumbItemId && cardOptions.inheritThumb !== false - && item.MediaType !== 'Photo' + && item.MediaType !== ItemMediaKind.Photo ) { imgType = ImageType.Thumb; imgTag = item.ParentThumbImageTag; @@ -117,12 +119,12 @@ function shouldShowPreferDisc( function shouldShowImageTagsPrimary(item: ItemDto): boolean { return ( - Boolean(item.ImageTags?.Primary) && (item.Type !== BaseItemKind.Episode || item.ChildCount !== 0) + Boolean(item.ImageTags?.Primary) && (item.Type !== ItemKind.Episode || item.ChildCount !== 0) ); } function shouldShowImageTagsThumb(item: ItemDto): boolean { - return item.Type === BaseItemKind.Season && Boolean(item.ImageTags?.Thumb); + return item.Type === ItemKind.Season && Boolean(item.ImageTags?.Thumb); } function shouldShowSeriesThumbImageTag( @@ -147,8 +149,8 @@ function shouldShowAlbumPrimaryImageTag(item: ItemDto): boolean { return Boolean(item.AlbumId) && Boolean(item.AlbumPrimaryImageTag); } -function shouldShowPreferThumb(itemType: NullableString, cardOptions: CardOptions): boolean { - return Boolean(cardOptions.preferThumb) && !(itemType === BaseItemKind.Program || itemType === BaseItemKind.Episode); +function shouldShowPreferThumb(itemType: ItemKind, cardOptions: CardOptions): boolean { + return Boolean(cardOptions.preferThumb) && !(itemType === ItemKind.Program || itemType === ItemKind.Episode); } function getCardImageInfo( diff --git a/src/components/indicators/useIndicator.tsx b/src/components/indicators/useIndicator.tsx index 7f16606359..993da54b5a 100644 --- a/src/components/indicators/useIndicator.tsx +++ b/src/components/indicators/useIndicator.tsx @@ -1,4 +1,3 @@ -import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import { LocationType } from '@jellyfin/sdk/lib/generated-client/models/location-type'; import React from 'react'; import Box from '@mui/material/Box'; @@ -13,9 +12,15 @@ import FolderIcon from '@mui/icons-material/Folder'; import PhotoAlbumIcon from '@mui/icons-material/PhotoAlbum'; import PhotoIcon from '@mui/icons-material/Photo'; import classNames from 'classnames'; + import datetime from 'scripts/datetime'; import itemHelper from 'components/itemHelper'; import AutoTimeProgressBar from 'elements/emby-progressbar/AutoTimeProgressBar'; + +import { ItemKind } from 'types/base/models/item-kind'; +import { ItemMediaKind } from 'types/base/models/item-media-kind'; +import { ItemStatus } from 'types/base/models/item-status'; + import type { NullableString } from 'types/base/common/shared/types'; import type { ItemDto } from 'types/base/models/item-dto'; import type { ProgressOptions } from 'types/progressOptions'; @@ -32,25 +37,25 @@ const getTypeIcon = (itemType: NullableString) => { }; const enableProgressIndicator = ( - itemType: NullableString, - itemMediaType: NullableString + itemType: ItemKind, + itemMediaType: ItemMediaKind ) => { return ( - (itemMediaType === 'Video' && itemType !== BaseItemKind.TvChannel) - || itemType === BaseItemKind.AudioBook - || itemType === 'AudioPodcast' + (itemMediaType === ItemMediaKind.Video && itemType !== ItemKind.TvChannel) + || itemType === ItemKind.AudioBook + || itemType === ItemKind.AudioPodcast ); }; const enableAutoTimeProgressIndicator = ( - itemType: NullableString, + itemType: ItemKind, itemStartDate: NullableString, itemEndDate: NullableString ) => { return ( - (itemType === BaseItemKind.Program - || itemType === 'Timer' - || itemType === BaseItemKind.Recording) + (itemType === ItemKind.Program + || itemType === ItemKind.Timer + || itemType === ItemKind.Recording) && Boolean(itemStartDate) && Boolean(itemEndDate) ); @@ -76,7 +81,7 @@ const useIndicator = (item: ItemDto) => { const getMissingIndicator = () => { if ( - item.Type === BaseItemKind.Episode + item.Type === ItemKind.Episode && item.LocationType === LocationType.Virtual ) { if (item.PremiereDate) { @@ -102,11 +107,11 @@ const useIndicator = (item: ItemDto) => { let status; - if (item.Type === 'SeriesTimer') { + if (item.Type === ItemKind.SeriesTimer) { return ; } else if (item.TimerId || item.SeriesTimerId) { - status = item.Status || 'Cancelled'; - } else if (item.Type === 'Timer') { + status = item.Status || ItemStatus.Cancelled; + } else if (item.Type === ItemKind.Timer) { status = item.Status; } else { return null; @@ -116,7 +121,7 @@ const useIndicator = (item: ItemDto) => { return ( ); @@ -198,7 +203,7 @@ const useIndicator = (item: ItemDto) => { const getProgressBar = (progressOptions?: ProgressOptions) => { if ( enableProgressIndicator(item.Type, item.MediaType) - && item.Type !== BaseItemKind.Recording + && item.Type !== ItemKind.Recording ) { const playedPercentage = progressOptions?.userData?.PlayedPercentage ? progressOptions.userData.PlayedPercentage : @@ -231,8 +236,8 @@ const useIndicator = (item: ItemDto) => { if (pct > 0 && pct < 100) { const isRecording = - item.Type === 'Timer' - || item.Type === BaseItemKind.Recording + item.Type === ItemKind.Timer + || item.Type === ItemKind.Recording || Boolean(item.TimerId); return ( = ({ )} {isEndsAtEnabled - && MediaType === 'Video' + && MediaType === ItemMediaKind.Video && RunTimeTicks && !StartDate && } diff --git a/src/components/mediainfo/usePrimaryMediaInfo.tsx b/src/components/mediainfo/usePrimaryMediaInfo.tsx index 0b5d60968a..b79ecf503b 100644 --- a/src/components/mediainfo/usePrimaryMediaInfo.tsx +++ b/src/components/mediainfo/usePrimaryMediaInfo.tsx @@ -1,22 +1,25 @@ -import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import * as userSettings from 'scripts/settings/userSettings'; import datetime from 'scripts/datetime'; import globalize from 'lib/globalize'; import itemHelper from '../itemHelper'; + +import { ItemKind } from 'types/base/models/item-kind'; +import { ItemMediaKind } from 'types/base/models/item-media-kind'; +import { ItemStatus } from 'types/base/models/item-status'; import type { NullableNumber, NullableString } from 'types/base/common/shared/types'; import type { ItemDto } from 'types/base/models/item-dto'; import type { MiscInfo } from 'types/mediaInfoItem'; function shouldShowFolderRuntime( - itemType: NullableString, - itemMediaType: NullableString + itemType: ItemKind, + itemMediaType: ItemMediaKind ): boolean { return ( - itemType === BaseItemKind.MusicAlbum - || itemMediaType === 'MusicArtist' - || itemType === BaseItemKind.Playlist - || itemMediaType === 'Playlist' - || itemMediaType === 'MusicGenre' + itemType === ItemKind.MusicAlbum + || itemMediaType === ItemMediaKind.MusicArtist + || itemType === ItemKind.Playlist + || itemMediaType === ItemMediaKind.Playlist + || itemMediaType === ItemMediaKind.MusicGenre ); } @@ -37,7 +40,7 @@ function addTrackCountOrItemCount( if (itemRunTimeTicks) { addMiscInfo({ text: datetime.getDisplayDuration(itemRunTimeTicks) }); } - } else if (itemType === BaseItemKind.PhotoAlbum || itemType === BaseItemKind.BoxSet) { + } else if (itemType === ItemKind.PhotoAlbum || itemType === ItemKind.BoxSet) { const count = itemChildCount; if (count) { addMiscInfo({ text: globalize.translate('ItemCount', count) }); @@ -46,22 +49,22 @@ function addTrackCountOrItemCount( } function addOriginalAirDateInfo( - itemType: NullableString, - itemMediaType: NullableString, + itemType: ItemKind, + itemMediaType: ItemMediaKind, isOriginalAirDateEnabled: boolean, itemPremiereDate: NullableString, addMiscInfo: (val: MiscInfo) => void ): void { if ( itemPremiereDate - && (itemType === BaseItemKind.Episode || itemMediaType === 'Photo') + && (itemType === ItemKind.Episode || itemMediaType === ItemMediaKind.Photo) && isOriginalAirDateEnabled ) { try { //don't modify date to locale if episode. Only Dates (not times) are stored, or editable in the edit metadata dialog const date = datetime.parseISO8601Date( itemPremiereDate, - itemType !== BaseItemKind.Episode + itemType !== ItemKind.Episode ); addMiscInfo({ text: datetime.toLocaleDateString(date) }); } catch (e) { @@ -71,14 +74,14 @@ function addOriginalAirDateInfo( } function addSeriesTimerInfo( - itemType: NullableString, + itemType: ItemKind, itemRecordAnyTime: boolean | undefined, itemStartDate: NullableString, itemRecordAnyChannel: boolean | undefined, itemChannelName: NullableString, addMiscInfo: (val: MiscInfo) => void ): void { - if (itemType === 'SeriesTimer') { + if (itemType === ItemKind.SeriesTimer) { if (itemRecordAnyTime) { addMiscInfo({ text: globalize.translate('Anytime') }); } else { @@ -145,9 +148,9 @@ function addProgramIndicators( isEpisodeTitleIndexNumberEnabled: boolean, addMiscInfo: (val: MiscInfo) => void ): void { - if (item.Type === BaseItemKind.Program || item.Type === 'Timer') { + if (item.Type === ItemKind.Program || item.Type === ItemKind.Timer) { let program = item; - if (item.Type === 'Timer' && item.ProgramInfo) { + if (item.Type === ItemKind.Timer && item.ProgramInfo) { program = item.ProgramInfo; } @@ -205,20 +208,20 @@ function addProgramTextInfo( function addStartDateInfo( itemStartDate: NullableString, - itemType: NullableString, + itemType: ItemKind, addMiscInfo: (val: MiscInfo) => void ): void { if ( itemStartDate - && itemType !== BaseItemKind.Program - && itemType !== 'SeriesTimer' - && itemType !== 'Timer' + && itemType !== ItemKind.Program + && itemType !== ItemKind.SeriesTimer + && itemType !== ItemKind.Timer ) { try { const date = datetime.parseISO8601Date(itemStartDate); addMiscInfo({ text: datetime.toLocaleDateString(date) }); - if (itemType !== BaseItemKind.Recording) { + if (itemType !== ItemKind.Recording) { addMiscInfo({ text: datetime.getDisplayTime(date) }); } } catch (e) { @@ -229,14 +232,14 @@ function addStartDateInfo( function addSeriesProductionYearInfo( itemProductionYear: NullableNumber, - itemType: NullableString, + itemType: ItemKind, isYearEnabled: boolean, - itemStatus: NullableString, + itemStatus: ItemStatus, itemEndDate: NullableString, addMiscInfo: (val: MiscInfo) => void ): void { - if (itemProductionYear && isYearEnabled && itemType === BaseItemKind.Series) { - if (itemStatus === 'Continuing') { + if (itemProductionYear && isYearEnabled && itemType === ItemKind.Series) { + if (itemStatus === ItemStatus.Continuing) { addMiscInfo({ text: globalize.translate( 'SeriesYearToPresent', @@ -279,20 +282,20 @@ function addproductionYearWithEndDate( function addYearInfo( isYearEnabled: boolean, - itemType: NullableString, - itemMediaType: NullableString, + itemType: ItemKind, + itemMediaType: ItemMediaKind, itemProductionYear: NullableNumber, itemPremiereDate: NullableString, addMiscInfo: (val: MiscInfo) => void ): void { if ( isYearEnabled - && itemType !== BaseItemKind.Series - && itemType !== BaseItemKind.Episode - && itemType !== BaseItemKind.Person - && itemMediaType !== 'Photo' - && itemType !== BaseItemKind.Program - && itemType !== BaseItemKind.Season + && itemType !== ItemKind.Series + && itemType !== ItemKind.Episode + && itemType !== ItemKind.Person + && itemMediaType !== ItemMediaKind.Photo + && itemType !== ItemKind.Program + && itemType !== ItemKind.Season ) { if (itemProductionYear) { addMiscInfo({ text: itemProductionYear }); @@ -321,21 +324,21 @@ function addVideo3DFormat( function addRunTimeInfo( itemRunTimeTicks: NullableNumber, - itemType: NullableString, + itemType: ItemKind, showFolderRuntime: boolean, isRuntimeEnabled: boolean, addMiscInfo: (val: MiscInfo) => void ): void { if ( itemRunTimeTicks - && itemType !== BaseItemKind.Series - && itemType !== BaseItemKind.Program - && itemType !== 'Timer' - && itemType !== BaseItemKind.Book + && itemType !== ItemKind.Series + && itemType !== ItemKind.Program + && itemType !== ItemKind.Timer + && itemType !== ItemKind.Book && !showFolderRuntime && isRuntimeEnabled ) { - if (itemType === BaseItemKind.Audio) { + if (itemType === ItemKind.Audio) { addMiscInfo({ text: datetime.getDisplayRunningTime(itemRunTimeTicks) }); } else { addMiscInfo({ text: datetime.getDisplayDuration(itemRunTimeTicks) }); @@ -345,15 +348,15 @@ function addRunTimeInfo( function addOfficialRatingInfo( itemOfficialRating: NullableString, - itemType: NullableString, + itemType: ItemKind, isOfficialRatingEnabled: boolean, addMiscInfo: (val: MiscInfo) => void ): void { if ( itemOfficialRating && isOfficialRatingEnabled - && itemType !== BaseItemKind.Season - && itemType !== BaseItemKind.Episode + && itemType !== ItemKind.Season + && itemType !== ItemKind.Episode ) { addMiscInfo({ text: itemOfficialRating, @@ -365,21 +368,21 @@ function addOfficialRatingInfo( function addAudioContainer( itemContainer: NullableString, isContainerEnabled: boolean, - itemType: NullableString, + itemType: ItemKind, addMiscInfo: (val: MiscInfo) => void ): void { - if (itemContainer && isContainerEnabled && itemType === BaseItemKind.Audio) { + if (itemContainer && isContainerEnabled && itemType === ItemKind.Audio) { addMiscInfo({ text: itemContainer }); } } function addPhotoSize( - itemMediaType: NullableString, + itemMediaType: ItemMediaKind, itemWidth: NullableNumber, itemHeight: NullableNumber, addMiscInfo: (val: MiscInfo) => void ): void { - if (itemMediaType === 'Photo' && itemWidth && itemHeight) { + if (itemMediaType === ItemMediaKind.Photo && itemWidth && itemHeight) { const size = `${itemWidth}x${itemHeight}`; addMiscInfo({ text: size }); diff --git a/src/hooks/useFetchItems.ts b/src/hooks/useFetchItems.ts index 5e162a294c..7d3bb0627b 100644 --- a/src/hooks/useFetchItems.ts +++ b/src/hooks/useFetchItems.ts @@ -1,7 +1,5 @@ import type { AxiosRequestConfig } from 'axios'; import type { ItemsApiGetItemsRequest, PlaylistsApiMoveItemRequest } from '@jellyfin/sdk/lib/generated-client'; -import type { BaseItemDto } from '@jellyfin/sdk/lib/generated-client/models/base-item-dto'; -import type { TimerInfoDto } from '@jellyfin/sdk/lib/generated-client/models/timer-info-dto'; import type { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind'; import { ImageType } from '@jellyfin/sdk/lib/generated-client/models/image-type'; import { ItemFields } from '@jellyfin/sdk/lib/generated-client/models/item-fields'; @@ -26,9 +24,13 @@ import globalize from 'lib/globalize'; import { type JellyfinApiContext, useApi } from './useApi'; import { getAlphaPickerQuery, getFieldsQuery, getFiltersQuery, getLimitQuery } from 'utils/items'; import { getProgramSections, getSuggestionSections } from 'utils/sections'; + import type { LibraryViewSettings, ParentId } from 'types/library'; import { type Section, type SectionType, SectionApiMethod } from 'types/sections'; import { LibraryTab } from 'types/libraryTab'; +import { ItemKind } from 'types/base/models/item-kind'; +import type { ItemDtoQueryResult } from 'types/base/models/item-dto-query-result'; +import type { ItemDto } from 'types/base/models/item-dto'; const fetchGetItems = async ( currentApi: JellyfinApiContext, @@ -46,7 +48,7 @@ const fetchGetItems = async ( signal: options?.signal } ); - return response.data; + return response.data as ItemDtoQueryResult; } }; @@ -61,7 +63,8 @@ export const useGetItems = (parametersOptions: ItemsApiGetItemsRequest) => { ], queryFn: ({ signal }) => fetchGetItems(currentApi, parametersOptions, { signal }), - gcTime: parametersOptions.sortBy?.includes(ItemSortBy.Random) ? 0 : undefined + gcTime: parametersOptions.sortBy?.includes(ItemSortBy.Random) ? 0 : undefined, + enabled: !!currentApi.api && !!currentApi.user?.Id }); }; @@ -95,8 +98,8 @@ export const useGetMovieRecommendations = (isMovieRecommendationEnabled: boolean const currentApi = useApi(); return useQuery({ queryKey: ['MovieRecommendations', isMovieRecommendationEnabled, parentId], - queryFn: ({ signal }) => - isMovieRecommendationEnabled ? fetchGetMovieRecommendations(currentApi, parentId, { signal }) : [] + queryFn: ({ signal }) => fetchGetMovieRecommendations(currentApi, parentId, { signal }), + enabled: !!currentApi.api && !!currentApi.user?.Id && isMovieRecommendationEnabled }); }; @@ -121,7 +124,7 @@ const fetchGetGenres = async ( signal: options?.signal } ); - return response.data; + return response.data as ItemDtoQueryResult; } }; @@ -131,7 +134,7 @@ export const useGetGenres = (itemType: BaseItemKind[], parentId: ParentId) => { queryKey: ['Genres', parentId], queryFn: ({ signal }) => fetchGetGenres(currentApi, itemType, parentId, { signal }), - enabled: !!parentId + enabled: !!currentApi.api && !!currentApi.user?.Id && !!parentId }); }; @@ -170,7 +173,7 @@ export const useGetStudios = (parentId: ParentId, itemType: BaseItemKind[]) => { queryKey: ['Studios', parentId, itemType], queryFn: ({ signal }) => fetchGetStudios(currentApi, parentId, itemType, { signal }), - enabled: !!parentId && !isLivetv + enabled: !!currentApi.api && !!currentApi.user?.Id && !!parentId && !isLivetv }); }; @@ -208,7 +211,7 @@ export const useGetQueryFiltersLegacy = ( fetchGetQueryFiltersLegacy(currentApi, parentId, itemType, { signal }), - enabled: !!parentId && !isLivetv + enabled: !!currentApi.api && !!currentApi.user?.Id && !!parentId && !isLivetv }); }; @@ -334,7 +337,7 @@ const fetchGetItemsViewByType = async ( break; } } - return response.data; + return response.data as ItemDtoQueryResult; } }; @@ -366,8 +369,8 @@ export const useGetItemsViewByType = ( ), refetchOnWindowFocus: false, placeholderData : keepPreviousData, - enabled: - [ + enabled: !!currentApi.api && !!currentApi.user?.Id + && [ LibraryTab.Movies, LibraryTab.Favorites, LibraryTab.Collections, @@ -413,13 +416,13 @@ export const usePlaylistsMoveItemMutation = () => { type GroupsUpcomingEpisodes = { name: string; - items: BaseItemDto[]; + items: ItemDto[]; }; -function groupsUpcomingEpisodes(items: BaseItemDto[]) { +function groupsUpcomingEpisodes(items: ItemDto[]) { const groups: GroupsUpcomingEpisodes[] = []; let currentGroupName = ''; - let currentGroup: BaseItemDto[] = []; + let currentGroup: ItemDto[] = []; for (const item of items) { let dateText = ''; @@ -483,7 +486,7 @@ const fetchGetGroupsUpcomingEpisodes = async ( signal: options?.signal } ); - const items = response.data.Items ?? []; + const items = (response.data.Items as ItemDto[]) || []; return groupsUpcomingEpisodes(items); } @@ -495,7 +498,7 @@ export const useGetGroupsUpcomingEpisodes = (parentId: ParentId) => { queryKey: ['GroupsUpcomingEpisodes', parentId], queryFn: ({ signal }) => fetchGetGroupsUpcomingEpisodes(currentApi, parentId, { signal }), - enabled: !!parentId + enabled: !!currentApi.api && !!currentApi.user?.Id && !!parentId }); }; @@ -573,17 +576,17 @@ export const useTogglePlayedMutation = () => { export type GroupsTimers = { name: string; - timerInfo: TimerInfoDto[]; + timerInfo: ItemDto[]; }; -function groupsTimers(timers: TimerInfoDto[], indexByDate?: boolean) { +function groupsTimers(timers: ItemDto[], indexByDate?: boolean) { const items = timers.map(function (t) { - t.Type = 'Timer'; + t.Type = ItemKind.Timer; return t; }); const groups: GroupsTimers[] = []; let currentGroupName = ''; - let currentGroup: TimerInfoDto[] = []; + let currentGroup: ItemDto[] = []; for (const item of items) { let dateText = ''; @@ -642,7 +645,7 @@ const fetchGetTimers = async ( } ); - const timers = response.data.Items ?? []; + const timers = (response.data.Items as ItemDto[]) || []; return groupsTimers(timers, indexByDate); } @@ -652,8 +655,8 @@ export const useGetTimers = (isUpcomingRecordingsEnabled: boolean, indexByDate?: const currentApi = useApi(); return useQuery({ queryKey: ['Timers', { isUpcomingRecordingsEnabled, indexByDate }], - queryFn: ({ signal }) => - isUpcomingRecordingsEnabled ? fetchGetTimers(currentApi, indexByDate, { signal }) : [] + queryFn: ({ signal }) => fetchGetTimers(currentApi, indexByDate, { signal }), + enabled: !!currentApi.api && !!currentApi.user?.Id && isUpcomingRecordingsEnabled }); }; @@ -838,13 +841,13 @@ const fetchGetSectionItems = async ( break; } } - return response; + return response as ItemDto[] || [] ; } }; type SectionWithItems = { section: Section; - items: BaseItemDto[]; + items: ItemDto[]; }; const getSectionsWithItems = async ( @@ -886,7 +889,7 @@ export const useGetSuggestionSectionsWithItems = ( queryKey: ['SuggestionSectionWithItems', { suggestionSectionType }], queryFn: ({ signal }) => getSectionsWithItems(currentApi, parentId, sections, suggestionSectionType, { signal }), - enabled: !!parentId + enabled: !!currentApi.api && !!currentApi.user?.Id && !!parentId }); }; @@ -898,7 +901,7 @@ export const useGetProgramsSectionsWithItems = ( const sections = getProgramSections(); return useQuery({ queryKey: ['ProgramSectionWithItems', { programSectionType }], - queryFn: ({ signal }) => getSectionsWithItems(currentApi, parentId, sections, programSectionType, { signal }) - + queryFn: ({ signal }) => getSectionsWithItems(currentApi, parentId, sections, programSectionType, { signal }), + enabled: !!currentApi.api && !!currentApi.user?.Id }); }; diff --git a/src/hooks/useItem.ts b/src/hooks/useItem.ts index 14af8b545a..f094a0b678 100644 --- a/src/hooks/useItem.ts +++ b/src/hooks/useItem.ts @@ -4,6 +4,7 @@ import { queryOptions, useQuery } from '@tanstack/react-query'; import type { AxiosRequestConfig } from 'axios'; import { useApi } from './useApi'; +import type { ItemDto } from 'types/base/models/item-dto'; const fetchItem = async ( api?: Api, @@ -16,7 +17,7 @@ const fetchItem = async ( const response = await getUserLibraryApi(api) .getItem({ userId, itemId }, options); - return response.data; + return response.data as ItemDto; }; export const getItemQuery = ( diff --git a/src/types/base/models/item-dto-query-result.ts b/src/types/base/models/item-dto-query-result.ts new file mode 100644 index 0000000000..8412f2efa9 --- /dev/null +++ b/src/types/base/models/item-dto-query-result.ts @@ -0,0 +1,7 @@ +import { ItemDto } from './item-dto'; + +export interface ItemDtoQueryResult { + Items?: Array; + TotalRecordCount?: number; + StartIndex?: number; +} diff --git a/src/types/base/models/item-dto.ts b/src/types/base/models/item-dto.ts index fab5f68024..241b6d69a0 100644 --- a/src/types/base/models/item-dto.ts +++ b/src/types/base/models/item-dto.ts @@ -1,7 +1,10 @@ -import type { BaseItemDto, BaseItemKind, CollectionTypeOptions, RecordingStatus, SearchHint, SeriesTimerInfoDto, TimerInfoDto, UserItemDataDto, VirtualFolderInfo } from '@jellyfin/sdk/lib/generated-client'; +import type { BaseItemDto, CollectionTypeOptions, SearchHint, SeriesTimerInfoDto, TimerInfoDto, UserItemDataDto, VirtualFolderInfo } from '@jellyfin/sdk/lib/generated-client'; +import type { ItemStatus } from './item-status'; +import type { ItemKind } from './item-kind'; +import type { ItemMediaKind } from './item-media-kind'; -type BaseItem = Omit; -type TimerInfo = Omit; +type BaseItem = Omit; +type TimerInfo = Omit; type SeriesTimerInfo = Omit; type SearchHintItem = Omit; type UserItem = Omit; @@ -12,11 +15,13 @@ export interface ItemDto extends BaseItem, TimerInfo, SeriesTimerInfo, SearchHin 'EndDate'?: string | null; 'Id'?: string | null; 'StartDate'?: string | null; - 'Type'?: BaseItemKind | string | null; - 'Status'?: RecordingStatus | string | null; + 'Type'?: ItemKind; + 'Status'?: ItemStatus; 'CollectionType'?: CollectionTypeOptions | string | null; 'Artists'?: Array | null; - 'MediaType'?: string | null; + 'MediaType'?: ItemMediaKind; 'Name'?: string | null; 'ItemId'?: string | null; + 'ProgramInfo'?: ItemDto; + 'CurrentProgram'?: ItemDto; } diff --git a/src/types/base/models/item-kind.ts b/src/types/base/models/item-kind.ts index d89f8cbeef..f0d6f32bbf 100644 --- a/src/types/base/models/item-kind.ts +++ b/src/types/base/models/item-kind.ts @@ -3,10 +3,9 @@ import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-ite export const ItemKind = { ...BaseItemKind, Timer: 'Timer', - SeriesTimer: 'SeriesTimer' + SeriesTimer: 'SeriesTimer', + AudioPodcast: 'AudioPodcast' } as const; // eslint-disable-next-line @typescript-eslint/no-redeclare -export type ItemKind = keyof typeof ItemKind; - -export type ItemType = ItemKind | null | undefined; +export type ItemKind = typeof ItemKind[keyof typeof ItemKind] | undefined; diff --git a/src/types/base/models/item-media-kind.ts b/src/types/base/models/item-media-kind.ts index 14fbe6a137..da88a72211 100644 --- a/src/types/base/models/item-media-kind.ts +++ b/src/types/base/models/item-media-kind.ts @@ -10,6 +10,4 @@ export const ItemMediaKind = { } as const; // eslint-disable-next-line @typescript-eslint/no-redeclare -export type ItemMediaKind = keyof typeof ItemMediaKind; - -export type ItemMediaType = ItemMediaKind | null | undefined; +export type ItemMediaKind = typeof ItemMediaKind[keyof typeof ItemMediaKind] | undefined; diff --git a/src/types/base/models/item-status.ts b/src/types/base/models/item-status.ts new file mode 100644 index 0000000000..de59359f73 --- /dev/null +++ b/src/types/base/models/item-status.ts @@ -0,0 +1,10 @@ +import { RecordingStatus } from '@jellyfin/sdk/lib/generated-client/models/recording-status'; +import { SeriesStatus } from '@jellyfin/sdk/lib/generated-client/models/series-status'; + +export const ItemStatus = { + ...RecordingStatus, + ...SeriesStatus +} as const; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export type ItemStatus = typeof ItemStatus[keyof typeof ItemStatus] | undefined;