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

Replace existence check with optional chaining (#5742)

This commit is contained in:
Peter Santos 2024-08-17 02:58:01 -04:00 committed by GitHub
parent cc22fbc042
commit 1da9b548ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 21 additions and 21 deletions

View file

@ -277,16 +277,16 @@ export function getCardImageUrl(item, apiClient, options, shape) {
let itemId = null;
/* eslint-disable sonarjs/no-duplicated-branches */
if (options.preferThumb && item.ImageTags && item.ImageTags.Thumb) {
if (options.preferThumb && item.ImageTags?.Thumb) {
imgType = 'Thumb';
imgTag = item.ImageTags.Thumb;
} else if ((options.preferBanner || shape === 'banner') && item.ImageTags && item.ImageTags.Banner) {
} else if ((options.preferBanner || shape === 'banner') && item.ImageTags?.Banner) {
imgType = 'Banner';
imgTag = item.ImageTags.Banner;
} else if (options.preferDisc && item.ImageTags && item.ImageTags.Disc) {
} else if (options.preferDisc && item.ImageTags?.Disc) {
imgType = 'Disc';
imgTag = item.ImageTags.Disc;
} else if (options.preferLogo && item.ImageTags && item.ImageTags.Logo) {
} else if (options.preferLogo && item.ImageTags?.Logo) {
imgType = 'Logo';
imgTag = item.ImageTags.Logo;
} else if (options.preferLogo && item.ParentLogoImageTag && item.ParentLogoItemId) {
@ -301,11 +301,11 @@ export function getCardImageUrl(item, apiClient, options, shape) {
imgType = 'Thumb';
imgTag = item.ParentThumbImageTag;
itemId = item.ParentThumbItemId;
} else if (options.preferThumb && item.BackdropImageTags && item.BackdropImageTags.length) {
} else if (options.preferThumb && item.BackdropImageTags?.length) {
imgType = 'Backdrop';
imgTag = item.BackdropImageTags[0];
forceName = true;
} else if (options.preferThumb && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length && options.inheritThumb !== false && item.Type === 'Episode') {
} else if (options.preferThumb && item.ParentBackdropImageTags?.length && options.inheritThumb !== false && item.Type === 'Episode') {
imgType = 'Backdrop';
imgTag = item.ParentBackdropImageTags[0];
itemId = item.ParentBackdropItemId;
@ -351,7 +351,7 @@ export function getCardImageUrl(item, apiClient, options, shape) {
if (primaryImageAspectRatio && uiAspect) {
coverImage = (Math.abs(primaryImageAspectRatio - uiAspect) / uiAspect) <= 0.2;
}
} else if (item.Type === 'Season' && item.ImageTags && item.ImageTags.Thumb) {
} else if (item.Type === 'Season' && item.ImageTags?.Thumb) {
imgType = 'Thumb';
imgTag = item.ImageTags.Thumb;
} else if (item.BackdropImageTags?.length) {
@ -571,7 +571,7 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
if (showOtherText) {
if (options.showParentTitle && parentTitleUnderneath) {
if (flags.isOuterFooter && item.AlbumArtists && item.AlbumArtists.length) {
if (flags.isOuterFooter && item.AlbumArtists?.length) {
item.AlbumArtists[0].Type = 'MusicArtist';
item.AlbumArtists[0].IsFolder = true;
lines.push(getTextActionButton(item.AlbumArtists[0], null, serverId));