diff --git a/src/components/backdrop/backdrop.js b/src/components/backdrop/backdrop.js index 8316803c64..4c64ea818a 100644 --- a/src/components/backdrop/backdrop.js +++ b/src/components/backdrop/backdrop.js @@ -178,7 +178,7 @@ function getItemImageUrls(item, imageOptions) { }); } - if (item.ParentBackdropItemId && item.ParentBackdropImageTags && item.ParentBackdropImageTags.length) { + if (item.ParentBackdropItemId && item.ParentBackdropImageTags?.length) { return item.ParentBackdropImageTags.map((imgTag, index) => { return apiClient.getScaledImageUrl(item.ParentBackdropItemId, Object.assign(imageOptions, { type: 'Backdrop', diff --git a/src/components/cardbuilder/cardBuilder.js b/src/components/cardbuilder/cardBuilder.js index 70dccf6db6..98421f9d48 100644 --- a/src/components/cardbuilder/cardBuilder.js +++ b/src/components/cardbuilder/cardBuilder.js @@ -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)); diff --git a/src/components/htmlMediaHelper.js b/src/components/htmlMediaHelper.js index fa1b343caa..4077d29447 100644 --- a/src/components/htmlMediaHelper.js +++ b/src/components/htmlMediaHelper.js @@ -152,7 +152,7 @@ export function seekOnPlaybackStart(instance, element, ticks, onMediaReady) { } export function applySrc(elem, src, options) { - if (window.Windows && options.mediaSource && options.mediaSource.IsLocal) { + if (window.Windows && options.mediaSource?.IsLocal) { return Windows.Storage.StorageFile.getFileFromPathAsync(options.url).then(function (file) { const playlist = new Windows.Media.Playback.MediaPlaybackList(); diff --git a/src/components/itemContextMenu.js b/src/components/itemContextMenu.js index 3e71c2a25f..f265eafbfe 100644 --- a/src/components/itemContextMenu.js +++ b/src/components/itemContextMenu.js @@ -316,7 +316,7 @@ export function getCommands(options) { } // Show Album Artist by default, as a song can have multiple artists, which specific one would this option refer to? // Although some albums can have multiple artists, it's not as common as songs. - if (options.openArtist !== false && item.AlbumArtists && item.AlbumArtists.length) { + if (options.openArtist !== false && item.AlbumArtists?.length) { commands.push({ name: globalize.translate('ViewAlbumArtist'), id: 'artist', @@ -609,7 +609,7 @@ function play(item, resume, queue, queueNext) { } let startPosition = 0; - if (resume && item.UserData && item.UserData.PlaybackPositionTicks) { + if (resume && item.UserData?.PlaybackPositionTicks) { startPosition = item.UserData.PlaybackPositionTicks; } diff --git a/src/components/itemMediaInfo/itemMediaInfo.js b/src/components/itemMediaInfo/itemMediaInfo.js index 517c25dafa..620578da8b 100644 --- a/src/components/itemMediaInfo/itemMediaInfo.js +++ b/src/components/itemMediaInfo/itemMediaInfo.js @@ -64,7 +64,7 @@ function getMediaSourceHtml(user, item, version) { if (version.Formats?.length) { html += `${createAttribute(globalize.translate('MediaInfoFormat'), version.Formats.join(','))}
`; } - if (version.Path && user && user.Policy.IsAdministrator) { + if (version.Path && user?.Policy.IsAdministrator) { html += `${createAttribute(globalize.translate('MediaInfoPath'), version.Path, true)}
`; } if (version.Size) { diff --git a/src/components/remotecontrol/remotecontrol.js b/src/components/remotecontrol/remotecontrol.js index 0c09ca4b7c..64201aa3aa 100644 --- a/src/components/remotecontrol/remotecontrol.js +++ b/src/components/remotecontrol/remotecontrol.js @@ -737,12 +737,12 @@ export default function () { } }); context.querySelector('.btnAudioTracks').addEventListener('click', function (e) { - if (currentPlayer && lastPlayerState && lastPlayerState.NowPlayingItem) { + if (currentPlayer && lastPlayerState?.NowPlayingItem) { showAudioMenu(context, currentPlayer, e.target); } }); context.querySelector('.btnSubtitles').addEventListener('click', function (e) { - if (currentPlayer && lastPlayerState && lastPlayerState.NowPlayingItem) { + if (currentPlayer && lastPlayerState?.NowPlayingItem) { showSubtitleMenu(context, currentPlayer, e.target); } }); diff --git a/src/components/slideshow/slideshow.js b/src/components/slideshow/slideshow.js index 7980a62c98..f6648981c9 100644 --- a/src/components/slideshow/slideshow.js +++ b/src/components/slideshow/slideshow.js @@ -92,7 +92,7 @@ function getImgUrl(item, user) { if (item.BackdropImageTags?.length) { return getBackdropImageUrl(item, imageOptions, apiClient); } else { - if (item.MediaType === 'Photo' && user && user.Policy.EnableContentDownloading) { + if (item.MediaType === 'Photo' && user?.Policy.EnableContentDownloading) { return apiClient.getItemDownloadUrl(item.Id); } imageOptions.type = 'Primary'; @@ -171,7 +171,7 @@ export default function (options) { if (actionButtonsOnTop) { html += getIcon('play_arrow', 'btnSlideshowPause slideshowButton', true); - if (appHost.supports('filedownload') && slideshowOptions.user && slideshowOptions.user.Policy.EnableContentDownloading) { + if (appHost.supports('filedownload') && slideshowOptions.user?.Policy.EnableContentDownloading) { html += getIcon('file_download', 'btnDownload slideshowButton', true); } if (appHost.supports('sharing')) { @@ -189,7 +189,7 @@ export default function (options) { html += '
'; html += getIcon('play_arrow', 'btnSlideshowPause slideshowButton', true, true); - if (appHost.supports('filedownload') && slideshowOptions.user && slideshowOptions.user.Policy.EnableContentDownloading) { + if (appHost.supports('filedownload') && slideshowOptions?.user.Policy.EnableContentDownloading) { html += getIcon('file_download', 'btnDownload slideshowButton', true); } if (appHost.supports('sharing')) { diff --git a/src/lib/scroller/index.js b/src/lib/scroller/index.js index 20258f88a2..0292cb5688 100644 --- a/src/lib/scroller/index.js +++ b/src/lib/scroller/index.js @@ -293,7 +293,7 @@ const scrollerFactory = function (frame, options) { immediate = true; } - if (!immediate && o.skipSlideToWhenVisible && fullItemPos && fullItemPos.isVisible) { + if (!immediate && o.skipSlideToWhenVisible && fullItemPos?.isVisible) { return; } diff --git a/src/plugins/chromecastPlayer/plugin.js b/src/plugins/chromecastPlayer/plugin.js index f113ce24e2..de77b2cf3d 100644 --- a/src/plugins/chromecastPlayer/plugin.js +++ b/src/plugins/chromecastPlayer/plugin.js @@ -716,7 +716,7 @@ class ChromecastPlayer { }); } - if (options.items.length > 1 && options && options.ids) { + if (options.items.length > 1 && options?.ids) { // Use the original request id array for sorting the result in the proper order options.items.sort(function (a, b) { return options.ids.indexOf(a.Id) - options.ids.indexOf(b.Id); diff --git a/src/plugins/syncPlay/core/Helper.js b/src/plugins/syncPlay/core/Helper.js index f43bef949f..09d5d63bb3 100644 --- a/src/plugins/syncPlay/core/Helper.js +++ b/src/plugins/syncPlay/core/Helper.js @@ -105,7 +105,7 @@ function mergePlaybackQueries(obj1, obj2) { } export function translateItemsForPlayback(apiClient, items, options) { - if (items.length > 1 && options && options.ids) { + if (items.length > 1 && options?.ids) { // Use the original request id array for sorting the result in the proper order. items.sort(function (a, b) { return options.ids.indexOf(a.Id) - options.ids.indexOf(b.Id);