1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #5932 from grafixeyehero/Add-ItemDtoQueryResult-ItemStatus

Add shared ItemStatus and ItemDtoQueryResult Type
This commit is contained in:
Bill Thornton 2024-08-21 11:41:48 -04:00 committed by GitHub
commit d232494a89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 219 additions and 183 deletions

View file

@ -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';

View file

@ -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,

View file

@ -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<CardImageContainerProps> = ({
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<CardImageContainerProps> = ({
indicator.getChildCountIndicator() :
indicator.getPlayedIndicator()}
{(item.Type === BaseItemKind.CollectionFolder
{(item.Type === ItemKind.CollectionFolder
|| item.CollectionType) && (
<RefreshIndicator item={item} />
)}

View file

@ -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';

View file

@ -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<CardOverlayButtonsProps> = ({
&& !cardOptions.overlayInfoButton
&& !cardOptions.cardLayout
) {
overlayPlayButton = item.MediaType === 'Video';
overlayPlayButton = item.MediaType === ItemMediaKind.Video;
}
const url = appRouter.getRouteUrl(item, {

View file

@ -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 {

View file

@ -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 }
);

View file

@ -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(