diff --git a/.eslintrc.js b/.eslintrc.js index a3594d87a8..3e01786246 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -73,7 +73,6 @@ module.exports = { 'sonarjs/cognitive-complexity': ['warn'], // TODO: Enable the following rules and fix issues 'sonarjs/max-switch-cases': ['off'], - 'sonarjs/no-collapsible-if': ['off'], 'sonarjs/no-duplicate-string': ['off'], 'sonarjs/no-duplicated-branches': ['off'], 'sonarjs/no-gratuitous-expressions': ['off'], diff --git a/src/components/appRouter.js b/src/components/appRouter.js index f2bc0e27b0..9bfdc85707 100644 --- a/src/components/appRouter.js +++ b/src/components/appRouter.js @@ -87,12 +87,10 @@ class AppRouter { path = path.replace(this.baseUrl(), ''); - if (this.currentRouteInfo && this.currentRouteInfo.path === path) { - // can't use this with home right now due to the back menu - if (this.currentRouteInfo.route.type !== 'home') { - loading.hide(); - return Promise.resolve(); - } + // can't use this with home right now due to the back menu + if (this.currentRouteInfo?.path === path && this.currentRouteInfo.route.type !== 'home') { + loading.hide(); + return Promise.resolve(); } this.promiseShow = new Promise((resolve) => { @@ -351,15 +349,13 @@ class AppRouter { onRequestFail(_e, data) { const apiClient = this; - if (data.status === 403) { - if (data.errorCode === 'ParentalControl') { - const isCurrentAllowed = appRouter.currentRouteInfo ? (appRouter.currentRouteInfo.route.anonymous || appRouter.currentRouteInfo.route.startup) : true; + if (data.status === 403 && data.errorCode === 'ParentalControl') { + const isCurrentAllowed = appRouter.currentRouteInfo ? (appRouter.currentRouteInfo.route.anonymous || appRouter.currentRouteInfo.route.startup) : true; - // Bounce to the login screen, but not if a password entry fails, obviously - if (!isCurrentAllowed) { - appRouter.showForcedLogoutMessage(globalize.translate('AccessRestrictedTryAgainLater')); - appRouter.showLocalLogin(apiClient.serverId()); - } + // Bounce to the login screen, but not if a password entry fails, obviously + if (!isCurrentAllowed) { + appRouter.showForcedLogoutMessage(globalize.translate('AccessRestrictedTryAgainLater')); + appRouter.showLocalLogin(apiClient.serverId()); } } } diff --git a/src/components/cardbuilder/cardBuilder.js b/src/components/cardbuilder/cardBuilder.js index b5f85c9a57..ebdc250d7a 100644 --- a/src/components/cardbuilder/cardBuilder.js +++ b/src/components/cardbuilder/cardBuilder.js @@ -790,10 +790,8 @@ import { appRouter } from '../appRouter'; const showOtherText = isOuterFooter ? !overlayText : overlayText; - if (isOuterFooter && options.cardLayout && layoutManager.mobile) { - if (options.cardFooterAside !== 'none') { - html += ``; - } + if (isOuterFooter && options.cardLayout && layoutManager.mobile && options.cardFooterAside !== 'none') { + html += ``; } const cssClass = options.centerText ? 'cardText cardTextCentered' : 'cardText'; @@ -803,33 +801,31 @@ import { appRouter } from '../appRouter'; const parentTitleUnderneath = item.Type === 'MusicAlbum' || item.Type === 'Audio' || item.Type === 'MusicVideo'; let titleAdded; - if (showOtherText) { - if ((options.showParentTitle || options.showParentTitleOrTitle) && !parentTitleUnderneath) { - if (isOuterFooter && item.Type === 'Episode' && item.SeriesName) { - if (item.SeriesId) { - lines.push(getTextActionButton({ - Id: item.SeriesId, - ServerId: serverId, - Name: item.SeriesName, - Type: 'Series', - IsFolder: true - })); - } else { - lines.push(escapeHtml(item.SeriesName)); + if (showOtherText && (options.showParentTitle || options.showParentTitleOrTitle) && !parentTitleUnderneath) { + if (isOuterFooter && item.Type === 'Episode' && item.SeriesName) { + if (item.SeriesId) { + lines.push(getTextActionButton({ + Id: item.SeriesId, + ServerId: serverId, + Name: item.SeriesName, + Type: 'Series', + IsFolder: true + })); + } else { + lines.push(escapeHtml(item.SeriesName)); + } + } else { + if (isUsingLiveTvNaming(item)) { + lines.push(escapeHtml(item.Name)); + + if (!item.EpisodeTitle && !item.IndexNumber) { + titleAdded = true; } } else { - if (isUsingLiveTvNaming(item)) { - lines.push(escapeHtml(item.Name)); + const parentTitle = item.SeriesName || item.Series || item.Album || item.AlbumArtist || ''; - if (!item.EpisodeTitle && !item.IndexNumber) { - titleAdded = true; - } - } else { - const parentTitle = item.SeriesName || item.Series || item.Album || item.AlbumArtist || ''; - - if (parentTitle || showTitle) { - lines.push(escapeHtml(parentTitle)); - } + if (parentTitle || showTitle) { + lines.push(escapeHtml(parentTitle)); } } } @@ -986,10 +982,8 @@ import { appRouter } from '../appRouter'; } } - if (options.showPersonRoleOrType) { - if (item.Role) { - lines.push(globalize.translate('PersonRole', escapeHtml(item.Role))); - } + if (options.showPersonRoleOrType && item.Role) { + lines.push(globalize.translate('PersonRole', escapeHtml(item.Role))); } } @@ -1009,13 +1003,11 @@ import { appRouter } from '../appRouter'; html += progressHtml; } - if (html) { - if (!isOuterFooter || logoUrl || options.cardLayout) { - html = '
' + html; + if (html && (!isOuterFooter || logoUrl || options.cardLayout)) { + html = '
' + html; - //cardFooter - html += '
'; - } + //cardFooter + html += '
'; } return html; diff --git a/src/components/cardbuilder/chaptercardbuilder.js b/src/components/cardbuilder/chaptercardbuilder.js index da8de34f9a..f479fb4c88 100644 --- a/src/components/cardbuilder/chaptercardbuilder.js +++ b/src/components/cardbuilder/chaptercardbuilder.js @@ -34,10 +34,8 @@ import ServerConnections from '../ServerConnections'; let shape = (options.backdropShape || 'backdrop'); - if (videoStream.Width && videoStream.Height) { - if ((videoStream.Width / videoStream.Height) <= 1.2) { - shape = (options.squareShape || 'square'); - } + if (videoStream.Width && videoStream.Height && (videoStream.Width / videoStream.Height) <= 1.2) { + shape = (options.squareShape || 'square'); } className += ` ${shape}Card`; diff --git a/src/components/focusManager.js b/src/components/focusManager.js index 0b0ae06211..740ff7c07d 100644 --- a/src/components/focusManager.js +++ b/src/components/focusManager.js @@ -384,10 +384,11 @@ import scrollManager from './scrollManager'; // See if there's a focusable container, and if so, send the focus command to that if (activeElement) { const nearestElementFocusableParent = dom.parentWithClass(nearestElement, 'focusable'); - if (nearestElementFocusableParent && nearestElementFocusableParent !== nearestElement) { - if (focusableContainer !== nearestElementFocusableParent) { - nearestElement = nearestElementFocusableParent; - } + if (nearestElementFocusableParent + && nearestElementFocusableParent !== nearestElement + && focusableContainer !== nearestElementFocusableParent + ) { + nearestElement = nearestElementFocusableParent; } } focus(nearestElement); diff --git a/src/components/itemContextMenu.js b/src/components/itemContextMenu.js index 34c10ffd33..6974f609ef 100644 --- a/src/components/itemContextMenu.js +++ b/src/components/itemContextMenu.js @@ -72,26 +72,25 @@ import toast from './toast/toast'; } } - if (item.IsFolder || item.Type === 'MusicArtist' || item.Type === 'MusicGenre') { - if (item.CollectionType !== 'livetv') { - if (options.shuffle !== false) { - commands.push({ - name: globalize.translate('Shuffle'), - id: 'shuffle', - icon: 'shuffle' - }); - } - } + if ((item.IsFolder || item.Type === 'MusicArtist' || item.Type === 'MusicGenre') + && item.CollectionType !== 'livetv' + && options.shuffle !== false + ) { + commands.push({ + name: globalize.translate('Shuffle'), + id: 'shuffle', + icon: 'shuffle' + }); } - if (item.MediaType === 'Audio' || item.Type === 'MusicAlbum' || item.Type === 'MusicArtist' || item.Type === 'MusicGenre') { - if (options.instantMix !== false && !itemHelper.isLocalItem(item)) { - commands.push({ - name: globalize.translate('InstantMix'), - id: 'instantmix', - icon: 'explore' - }); - } + if ((item.MediaType === 'Audio' || item.Type === 'MusicAlbum' || item.Type === 'MusicArtist' || item.Type === 'MusicGenre') + && options.instantMix !== false && !itemHelper.isLocalItem(item) + ) { + commands.push({ + name: globalize.translate('InstantMix'), + id: 'instantmix', + icon: 'explore' + }); } if (commands.length) { @@ -180,57 +179,49 @@ import toast from './toast/toast'; } const canEdit = itemHelper.canEdit(user, item); - if (canEdit) { - if (options.edit !== false && item.Type !== 'SeriesTimer') { - const text = (item.Type === 'Timer' || item.Type === 'SeriesTimer') ? globalize.translate('Edit') : globalize.translate('EditMetadata'); - commands.push({ - name: text, - id: 'edit', - icon: 'edit' - }); - } + if (canEdit && options.edit !== false && item.Type !== 'SeriesTimer') { + const text = (item.Type === 'Timer' || item.Type === 'SeriesTimer') ? globalize.translate('Edit') : globalize.translate('EditMetadata'); + commands.push({ + name: text, + id: 'edit', + icon: 'edit' + }); } - if (itemHelper.canEditImages(user, item)) { - if (options.editImages !== false) { - commands.push({ - name: globalize.translate('EditImages'), - id: 'editimages', - icon: 'image' - }); - } + if (itemHelper.canEditImages(user, item) && options.editImages !== false) { + commands.push({ + name: globalize.translate('EditImages'), + id: 'editimages', + icon: 'image' + }); } - if (canEdit) { - if (item.MediaType === 'Video' && item.Type !== 'TvChannel' && item.Type !== 'Program' && item.LocationType !== 'Virtual' && !(item.Type === 'Recording' && item.Status !== 'Completed')) { - if (options.editSubtitles !== false) { - commands.push({ - name: globalize.translate('EditSubtitles'), - id: 'editsubtitles', - icon: 'closed_caption' - }); - } - } + if (canEdit && item.MediaType === 'Video' && item.Type !== 'TvChannel' && item.Type !== 'Program' + && item.LocationType !== 'Virtual' + && !(item.Type === 'Recording' && item.Status !== 'Completed') + && options.editSubtitles !== false + ) { + commands.push({ + name: globalize.translate('EditSubtitles'), + id: 'editsubtitles', + icon: 'closed_caption' + }); } - if (options.identify !== false) { - if (itemHelper.canIdentify(user, item)) { - commands.push({ - name: globalize.translate('Identify'), - id: 'identify', - icon: 'edit' - }); - } + if (options.identify !== false && itemHelper.canIdentify(user, item)) { + commands.push({ + name: globalize.translate('Identify'), + id: 'identify', + icon: 'edit' + }); } - if (item.MediaSources) { - if (options.moremediainfo !== false) { - commands.push({ - name: globalize.translate('MoreMediaInfo'), - id: 'moremediainfo', - icon: 'info' - }); - } + if (item.MediaSources && options.moremediainfo !== false) { + commands.push({ + name: globalize.translate('MoreMediaInfo'), + id: 'moremediainfo', + icon: 'info' + }); } if (item.Type === 'Program' && options.record !== false) { @@ -240,11 +231,7 @@ import toast from './toast/toast'; id: 'record', icon: 'fiber_manual_record' }); - } - } - - if (item.Type === 'Program' && options.record !== false) { - if (!item.TimerId) { + } else { commands.push({ name: globalize.translate('Record'), id: 'record', @@ -277,26 +264,20 @@ import toast from './toast/toast'; }); } - if (!restrictOptions) { - if (options.share === true) { - if (itemHelper.canShare(item, user)) { - commands.push({ - name: globalize.translate('Share'), - id: 'share', - icon: 'share' - }); - } - } + if (!restrictOptions && options.share === true && itemHelper.canShare(item, user)) { + commands.push({ + name: globalize.translate('Share'), + id: 'share', + icon: 'share' + }); } - if (options.sync !== false) { - if (itemHelper.canSync(user, item)) { - commands.push({ - name: globalize.translate('Sync'), - id: 'sync', - icon: 'sync' - }); - } + if (options.sync !== false && itemHelper.canSync(user, item)) { + commands.push({ + name: globalize.translate('Sync'), + id: 'sync', + icon: 'sync' + }); } if (options.openAlbum !== false && item.AlbumId && item.MediaType !== 'Photo') { diff --git a/src/components/itemHelper.js b/src/components/itemHelper.js index 6773a6c79f..2a181d3424 100644 --- a/src/components/itemHelper.js +++ b/src/components/itemHelper.js @@ -48,10 +48,8 @@ export function getDisplayName(item, options = {}) { export function supportsAddingToCollection(item) { const invalidTypes = ['Genre', 'MusicGenre', 'Studio', 'UserView', 'CollectionFolder', 'Audio', 'Program', 'Timer', 'SeriesTimer']; - if (item.Type === 'Recording') { - if (item.Status !== 'Completed') { - return false; - } + if (item.Type === 'Recording' && item.Status !== 'Completed') { + return false; } return !item.CollectionType && invalidTypes.indexOf(item.Type) === -1 && item.MediaType !== 'Photo' && !isLocalItem(item); @@ -74,10 +72,8 @@ export function supportsAddingToPlaylist(item) { return false; } - if (item.Type === 'Recording') { - if (item.Status !== 'Completed') { - return false; - } + if (item.Type === 'Recording' && item.Status !== 'Completed') { + return false; } if (isLocalItem(item)) { @@ -109,10 +105,8 @@ export function canEdit(user, item) { return false; } - if (item.Type === 'Recording') { - if (item.Status !== 'Completed') { - return false; - } + if (item.Type === 'Recording' && item.Status !== 'Completed') { + return false; } if (isLocalItem(item)) { @@ -133,23 +127,17 @@ export function isLocalItem(item) { export function canIdentify (user, item) { const itemType = item.Type; - if (itemType === 'Movie' || - itemType === 'Trailer' || - itemType === 'Series' || - itemType === 'BoxSet' || - itemType === 'Person' || - itemType === 'Book' || - itemType === 'MusicAlbum' || - itemType === 'MusicArtist' || - itemType === 'MusicVideo') { - if (user.Policy.IsAdministrator) { - if (!isLocalItem(item)) { - return true; - } - } - } - - return false; + return (itemType === 'Movie' + || itemType === 'Trailer' + || itemType === 'Series' + || itemType === 'BoxSet' + || itemType === 'Person' + || itemType === 'Book' + || itemType === 'MusicAlbum' + || itemType === 'MusicArtist' + || itemType === 'MusicVideo') + && user.Policy.IsAdministrator + && !isLocalItem(item); } export function canEditImages (user, item) { @@ -167,10 +155,8 @@ export function canEditImages (user, item) { return false; } - if (item.Type === 'Recording') { - if (item.Status !== 'Completed') { - return false; - } + if (item.Type === 'Recording' && item.Status !== 'Completed') { + return false; } return itemType !== 'Timer' && itemType !== 'SeriesTimer' && canEdit(user, item) && !isLocalItem(item); @@ -201,10 +187,8 @@ export function canShare (item, user) { if (item.Type === 'SeriesTimer') { return false; } - if (item.Type === 'Recording') { - if (item.Status !== 'Completed') { - return false; - } + if (item.Type === 'Recording' && item.Status !== 'Completed') { + return false; } if (isLocalItem(item)) { return false; @@ -301,11 +285,10 @@ export function canRefreshMetadata (item, user) { return false; } - if (item.Type !== 'Timer' && item.Type !== 'SeriesTimer' && item.Type !== 'Program' && item.Type !== 'TvChannel' && !(item.Type === 'Recording' && item.Status !== 'Completed')) { - if (!isLocalItem(item)) { - return true; - } - } + return item.Type !== 'Timer' && item.Type !== 'SeriesTimer' && item.Type !== 'Program' + && item.Type !== 'TvChannel' + && !(item.Type === 'Recording' && item.Status !== 'Completed') + && !isLocalItem(item); } return false; diff --git a/src/components/itemsrefresher.js b/src/components/itemsrefresher.js index 5a5d93e15d..2799a00b1a 100644 --- a/src/components/itemsrefresher.js +++ b/src/components/itemsrefresher.js @@ -94,16 +94,14 @@ function onPlaybackStopped(e, stopInfo) { const state = stopInfo.state; const eventsToMonitor = getEventsToMonitor(instance); - if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Video') { + if (state.NowPlayingItem?.MediaType === 'Video') { if (eventsToMonitor.indexOf('videoplayback') !== -1) { instance.notifyRefreshNeeded(true); return; } - } else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') { - if (eventsToMonitor.indexOf('audioplayback') !== -1) { - instance.notifyRefreshNeeded(true); - return; - } + } else if (state.NowPlayingItem?.MediaType === 'Audio' && eventsToMonitor.indexOf('audioplayback') !== -1) { + instance.notifyRefreshNeeded(true); + return; } } diff --git a/src/components/listview/listview.js b/src/components/listview/listview.js index ee75656367..eeb2946ec0 100644 --- a/src/components/listview/listview.js +++ b/src/components/listview/listview.js @@ -328,10 +328,8 @@ import ServerConnections from '../ServerConnections'; textlines.push(datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate))); } - if (options.showChannel) { - if (item.ChannelName) { - textlines.push(item.ChannelName); - } + if (options.showChannel && item.ChannelName) { + textlines.push(item.ChannelName); } let parentTitle = null; @@ -370,10 +368,8 @@ import ServerConnections from '../ServerConnections'; } if (item.IsFolder) { - if (options.artist !== false) { - if (item.AlbumArtist && item.Type === 'MusicAlbum') { + if (options.artist !== false && item.AlbumArtist && item.Type === 'MusicAlbum') { textlines.push(item.AlbumArtist); - } } } else { if (options.artist) { @@ -386,10 +382,8 @@ import ServerConnections from '../ServerConnections'; } } - if (item.Type === 'TvChannel') { - if (item.CurrentProgram) { - textlines.push(itemHelper.getDisplayName(item.CurrentProgram)); - } + if (item.Type === 'TvChannel' && item.CurrentProgram) { + textlines.push(itemHelper.getDisplayName(item.CurrentProgram)); } cssClass = 'listItemBody'; @@ -405,19 +399,17 @@ import ServerConnections from '../ServerConnections'; html += getTextLinesHtml(textlines, isLargeStyle); - if (options.mediaInfo !== false) { - if (!enableSideMediaInfo) { - const mediaInfoClass = 'secondary listItemMediaInfo listItemBodyText'; + if (options.mediaInfo !== false && !enableSideMediaInfo) { + const mediaInfoClass = 'secondary listItemMediaInfo listItemBodyText'; - html += `
`; - html += mediaInfo.getPrimaryMediaInfoHtml(item, { - episodeTitle: false, - originalAirDate: false, - subtitles: false + html += `
`; + html += mediaInfo.getPrimaryMediaInfoHtml(item, { + episodeTitle: false, + originalAirDate: false, + subtitles: false - }); - html += '
'; - } + }); + html += '
'; } if (enableOverview && item.Overview) { @@ -428,20 +420,18 @@ import ServerConnections from '../ServerConnections'; html += ''; - if (options.mediaInfo !== false) { - if (enableSideMediaInfo) { - html += '
'; - html += mediaInfo.getPrimaryMediaInfoHtml(item, { + if (options.mediaInfo !== false && enableSideMediaInfo) { + html += '
'; + html += mediaInfo.getPrimaryMediaInfoHtml(item, { - year: false, - container: false, - episodeTitle: false, - criticRating: false, - endsAt: false + year: false, + container: false, + episodeTitle: false, + criticRating: false, + endsAt: false - }); - html += '
'; - } + }); + html += '
'; } if (!options.recordButton && (item.Type === 'Timer' || item.Type === 'Program')) { diff --git a/src/components/mediainfo/mediainfo.js b/src/components/mediainfo/mediainfo.js index f21bc8f666..6f7876fcf1 100644 --- a/src/components/mediainfo/mediainfo.js +++ b/src/components/mediainfo/mediainfo.js @@ -129,17 +129,18 @@ import '../../elements/emby-button/emby-button'; } } - if ((item.Type === 'Episode' || item.MediaType === 'Photo') && options.originalAirDate !== false) { - if (item.PremiereDate) { - try { - //don't modify date to locale if episode. Only Dates (not times) are stored, or editable in the edit metadata dialog - date = datetime.parseISO8601Date(item.PremiereDate, item.Type !== 'Episode'); + if ((item.Type === 'Episode' || item.MediaType === 'Photo') + && options.originalAirDate !== false + && item.PremiereDate + ) { + try { + //don't modify date to locale if episode. Only Dates (not times) are stored, or editable in the edit metadata dialog + date = datetime.parseISO8601Date(item.PremiereDate, item.Type !== 'Episode'); - text = datetime.toLocaleDateString(date); - miscInfo.push(text); - } catch (e) { - console.error('error parsing date:', item.PremiereDate); - } + text = datetime.toLocaleDateString(date); + miscInfo.push(text); + } catch (e) { + console.error('error parsing date:', item.PremiereDate); } } @@ -239,17 +240,17 @@ import '../../elements/emby-button/emby-button'; } } - if (options.year !== false) { - if (item.Type !== 'Series' && item.Type !== 'Episode' && item.Type !== 'Person' && item.MediaType !== 'Photo' && item.Type !== 'Program' && item.Type !== 'Season') { - if (item.ProductionYear) { - miscInfo.push(item.ProductionYear); - } else if (item.PremiereDate) { - try { - text = datetime.parseISO8601Date(item.PremiereDate).getFullYear(); - miscInfo.push(text); - } catch (e) { - console.error('error parsing date:', item.PremiereDate); - } + if (options.year !== false && item.Type !== 'Series' && item.Type !== 'Episode' && item.Type !== 'Person' + && item.MediaType !== 'Photo' && item.Type !== 'Program' && item.Type !== 'Season' + ) { + if (item.ProductionYear) { + miscInfo.push(item.ProductionYear); + } else if (item.PremiereDate) { + try { + text = datetime.parseISO8601Date(item.PremiereDate).getFullYear(); + miscInfo.push(text); + } catch (e) { + console.error('error parsing date:', item.PremiereDate); } } } @@ -314,14 +315,12 @@ import '../../elements/emby-button/emby-button'; } export function getEndsAt(item) { - if (item.MediaType === 'Video' && item.RunTimeTicks) { - if (!item.StartDate) { - let endDate = new Date().getTime() + (item.RunTimeTicks / 10000); - endDate = new Date(endDate); + if (item.MediaType === 'Video' && item.RunTimeTicks && !item.StartDate) { + let endDate = new Date().getTime() + (item.RunTimeTicks / 10000); + endDate = new Date(endDate); - const displayTime = datetime.getDisplayTime(endDate); - return globalize.translate('EndsAtValue', displayTime); - } + const displayTime = datetime.getDisplayTime(endDate); + return globalize.translate('EndsAtValue', displayTime); } return null; diff --git a/src/components/nowPlayingBar/nowPlayingBar.js b/src/components/nowPlayingBar/nowPlayingBar.js index ddf0544727..b39c8bff00 100644 --- a/src/components/nowPlayingBar/nowPlayingBar.js +++ b/src/components/nowPlayingBar/nowPlayingBar.js @@ -444,12 +444,10 @@ import { appRouter } from '../appRouter'; options = options || {}; options.type = options.type || 'Primary'; - if (options.type === 'Primary') { - if (item.SeriesPrimaryImageTag) { - options.tag = item.SeriesPrimaryImageTag; + if (options.type === 'Primary' && item.SeriesPrimaryImageTag) { + options.tag = item.SeriesPrimaryImageTag; - return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options); - } + return ServerConnections.getApiClient(item.ServerId).getScaledImageUrl(item.SeriesId, options); } if (options.type === 'Thumb') { diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 5d0f371f7d..1cbd99950a 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -44,10 +44,8 @@ function triggerPlayerChange(playbackManagerInstance, newPlayer, newTarget, prev return; } - if (newTarget && previousTargetInfo) { - if (newTarget.id === previousTargetInfo.id) { - return; - } + if (newTarget && previousTargetInfo && newTarget.id === previousTargetInfo.id) { + return; } Events.trigger(playbackManagerInstance, 'playerchange', [newPlayer, newTarget, previousPlayer]); @@ -501,10 +499,10 @@ function getPlaybackInfo(player, } // lastly, enforce player overrides for special situations - if (query.EnableDirectStream !== false) { - if (player.supportsPlayMethod && !player.supportsPlayMethod('DirectStream', item)) { - query.EnableDirectStream = false; - } + if (query.EnableDirectStream !== false + && player.supportsPlayMethod && !player.supportsPlayMethod('DirectStream', item) + ) { + query.EnableDirectStream = false; } if (player.getDirectPlayProtocols) { @@ -569,10 +567,10 @@ function getLiveStream(player, apiClient, item, playSessionId, deviceProfile, ma } // lastly, enforce player overrides for special situations - if (query.EnableDirectStream !== false) { - if (player.supportsPlayMethod && !player.supportsPlayMethod('DirectStream', item)) { - query.EnableDirectStream = false; - } + if (query.EnableDirectStream !== false + && player.supportsPlayMethod && !player.supportsPlayMethod('DirectStream', item) + ) { + query.EnableDirectStream = false; } return apiClient.ajax({ @@ -963,10 +961,8 @@ class PlaybackManager { self.isPlaying = function (player) { player = player || self._currentPlayer; - if (player) { - if (player.isPlaying) { - return player.isPlaying(); - } + if (player?.isPlaying) { + return player.isPlaying(); } return player != null && player.currentSrc() != null; @@ -975,10 +971,8 @@ class PlaybackManager { self.isPlayingMediaType = function (mediaType, player) { player = player || self._currentPlayer; - if (player) { - if (player.isPlaying) { - return player.isPlaying(mediaType); - } + if (player?.isPlaying) { + return player.isPlaying(mediaType); } if (self.isPlaying(player)) { @@ -1027,10 +1021,8 @@ class PlaybackManager { return true; } - if (item.LocationType === 'Virtual') { - if (itemType !== 'Program') { - return false; - } + if (item.LocationType === 'Virtual' && itemType !== 'Program') { + return false; } if (itemType === 'Program') { @@ -3300,10 +3292,10 @@ class PlaybackManager { reportPlayback(self, state, player, reportPlaylist, serverId, 'reportPlaybackProgress', progressEventName); } - if (streamInfo && streamInfo.liveStreamId) { - if (new Date().getTime() - (streamInfo.lastMediaInfoQuery || 0) >= 600000) { - getLiveStreamMediaInfo(player, streamInfo, self.currentMediaSource(player), streamInfo.liveStreamId, serverId); - } + if (streamInfo?.liveStreamId + && (new Date().getTime() - (streamInfo.lastMediaInfoQuery || 0) >= 600000) + ) { + getLiveStreamMediaInfo(player, streamInfo, self.currentMediaSource(player), streamInfo.liveStreamId, serverId); } } } @@ -3568,10 +3560,8 @@ class PlaybackManager { } getBufferedRanges(player = this._currentPlayer) { - if (player) { - if (player.getBufferedRanges) { - return player.getBufferedRanges(); - } + if (player?.getBufferedRanges) { + return player.getBufferedRanges(); } return []; @@ -3842,19 +3832,15 @@ class PlaybackManager { removeActivePlayer(name) { const playerInfo = this.getPlayerInfo(); - if (playerInfo) { - if (playerInfo.name === name) { - this.setDefaultPlayerActive(); - } + if (playerInfo?.name === name) { + this.setDefaultPlayerActive(); } } removeActiveTarget(id) { const playerInfo = this.getPlayerInfo(); - if (playerInfo) { - if (playerInfo.id === id) { - this.setDefaultPlayerActive(); - } + if (playerInfo?.id === id) { + this.setDefaultPlayerActive(); } } diff --git a/src/components/playback/playerSelectionMenu.js b/src/components/playback/playerSelectionMenu.js index f7eea17be1..9cbe2e5ac0 100644 --- a/src/components/playback/playerSelectionMenu.js +++ b/src/components/playback/playerSelectionMenu.js @@ -29,10 +29,8 @@ function mirrorIfEnabled(info) { if (info && playbackManager.enableDisplayMirroring()) { const getPlayerInfo = playbackManager.getPlayerInfo(); - if (getPlayerInfo) { - if (!getPlayerInfo.isLocalPlayer && getPlayerInfo.supportedCommands.indexOf('DisplayContent') !== -1) { - mirrorItem(info, playbackManager.getCurrentPlayer()); - } + if (getPlayerInfo && !getPlayerInfo.isLocalPlayer && getPlayerInfo.supportedCommands.indexOf('DisplayContent') !== -1) { + mirrorItem(info, playbackManager.getCurrentPlayer()); } } } @@ -85,11 +83,9 @@ function getIcon(target) { export function show(button) { const currentPlayerInfo = playbackManager.getPlayerInfo(); - if (currentPlayerInfo) { - if (!currentPlayerInfo.isLocalPlayer) { - showActivePlayerMenu(currentPlayerInfo); - return; - } + if (currentPlayerInfo && !currentPlayerInfo.isLocalPlayer) { + showActivePlayerMenu(currentPlayerInfo); + return; } const currentPlayerId = currentPlayerInfo ? currentPlayerInfo.id : null; diff --git a/src/components/recordingcreator/recordingbutton.js b/src/components/recordingcreator/recordingbutton.js index a05a44b2e5..f2d5376ea0 100644 --- a/src/components/recordingcreator/recordingbutton.js +++ b/src/components/recordingcreator/recordingbutton.js @@ -106,10 +106,8 @@ function getIndicatorIcon(item) { return 'fiber_manual_record'; } - if (item.SeriesTimerId) { - if (status !== 'Cancelled') { - return 'fiber_smart_record'; - } + if (item.SeriesTimerId && status !== 'Cancelled') { + return 'fiber_smart_record'; } return 'fiber_manual_record'; diff --git a/src/components/recordingcreator/recordingfields.js b/src/components/recordingcreator/recordingfields.js index 179b472bc3..ffc43b4bb4 100644 --- a/src/components/recordingcreator/recordingfields.js +++ b/src/components/recordingcreator/recordingfields.js @@ -63,15 +63,10 @@ function onTimerChangedExternally(e, apiClient, data) { const options = this.options; let refresh = false; - if (data.Id) { - if (this.TimerId === data.Id) { - refresh = true; - } - } - if (data.ProgramId && options) { - if (options.programId === data.ProgramId) { - refresh = true; - } + if (data.Id && this.TimerId === data.Id) { + refresh = true; + } else if (data.ProgramId && options && options.programId === data.ProgramId) { + refresh = true; } if (refresh) { @@ -83,15 +78,11 @@ function onSeriesTimerChangedExternally(e, apiClient, data) { const options = this.options; let refresh = false; - if (data.Id) { - if (this.SeriesTimerId === data.Id) { - refresh = true; - } + if (data.Id && this.SeriesTimerId === data.Id) { + refresh = true; } - if (data.ProgramId && options) { - if (options.programId === data.ProgramId) { - refresh = true; - } + if (data.ProgramId && options && options.programId === data.ProgramId) { + refresh = true; } if (refresh) { diff --git a/src/components/slideshow/slideshow.js b/src/components/slideshow/slideshow.js index 1dd5751129..1112a57c32 100644 --- a/src/components/slideshow/slideshow.js +++ b/src/components/slideshow/slideshow.js @@ -46,11 +46,9 @@ function getImageUrl(item, options, apiClient) { return apiClient.getScaledImageUrl(item.Id, options); } - if (options.type === 'Primary') { - if (item.AlbumId && item.AlbumPrimaryImageTag) { - options.tag = item.AlbumPrimaryImageTag; - return apiClient.getScaledImageUrl(item.AlbumId, options); - } + if (options.type === 'Primary' && item.AlbumId && item.AlbumPrimaryImageTag) { + options.tag = item.AlbumPrimaryImageTag; + return apiClient.getScaledImageUrl(item.AlbumId, options); } return null; diff --git a/src/components/subtitleeditor/subtitleeditor.js b/src/components/subtitleeditor/subtitleeditor.js index ead71f9cee..35d4943c58 100644 --- a/src/components/subtitleeditor/subtitleeditor.js +++ b/src/components/subtitleeditor/subtitleeditor.js @@ -114,10 +114,8 @@ function fillSubtitleList(context, item) { itemHtml += ''; itemHtml += ''; - if (!layoutManager.tv) { - if (s.Path) { - itemHtml += ''; - } + if (!layoutManager.tv && s.Path) { + itemHtml += ''; } itemHtml += ''; diff --git a/src/controllers/dashboard/dashboard.js b/src/controllers/dashboard/dashboard.js index a6fe46b295..1f260f6d76 100644 --- a/src/controllers/dashboard/dashboard.js +++ b/src/controllers/dashboard/dashboard.js @@ -800,13 +800,11 @@ import confirm from '../../components/confirm/confirm'; }); } - if (ApiClient.isMinServerVersion('3.4.1.25')) { - if (!page.serverActivityLog) { - page.serverActivityLog = new ActivityLog({ - serverId: ApiClient.serverId(), - element: page.querySelector('.serverActivityItems') - }); - } + if (!page.serverActivityLog) { + page.serverActivityLog = new ActivityLog({ + serverId: ApiClient.serverId(), + element: page.querySelector('.serverActivityItems') + }); } refreshActiveRecordings(view, apiClient); diff --git a/src/elements/emby-input/emby-input.js b/src/elements/emby-input/emby-input.js index f9ea23f2ea..f62bcbf345 100644 --- a/src/elements/emby-input/emby-input.js +++ b/src/elements/emby-input/emby-input.js @@ -85,13 +85,9 @@ import 'webcomponents.js/webcomponents-lite'; passive: true }); - if (browser.orsay) { - if (this === document.activeElement) { - //Make sure the IME pops up if this is the first/default element on the page - if (document.attachIME) { - document.attachIME(this); - } - } + //Make sure the IME pops up if this is the first/default element on the page + if (browser.orsay && this === document.activeElement && document.attachIME) { + document.attachIME(this); } }; diff --git a/src/elements/emby-itemscontainer/emby-itemscontainer.js b/src/elements/emby-itemscontainer/emby-itemscontainer.js index 37edb8224c..4752613ddd 100644 --- a/src/elements/emby-itemscontainer/emby-itemscontainer.js +++ b/src/elements/emby-itemscontainer/emby-itemscontainer.js @@ -21,10 +21,8 @@ import Sortable from 'sortablejs'; const itemsContainer = this; const multiSelect = itemsContainer.multiSelect; - if (multiSelect) { - if (multiSelect.onContainerClick.call(itemsContainer, e) === false) { - return; - } + if (multiSelect?.onContainerClick.call(itemsContainer, e) === false) { + return; } itemShortcuts.onClick.call(itemsContainer, e); @@ -259,11 +257,9 @@ import Sortable from 'sortablejs'; itemsContainer.notifyRefreshNeeded(true); return; } - } else if (state.NowPlayingItem && state.NowPlayingItem.MediaType === 'Audio') { - if (eventsToMonitor.indexOf('audioplayback') !== -1) { - itemsContainer.notifyRefreshNeeded(true); - return; - } + } else if (state.NowPlayingItem?.MediaType === 'Audio' && eventsToMonitor.indexOf('audioplayback') !== -1) { + itemsContainer.notifyRefreshNeeded(true); + return; } } @@ -298,10 +294,8 @@ import Sortable from 'sortablejs'; } } - if (layoutManager.desktop || layoutManager.mobile) { - if (this.getAttribute('data-multiselect') !== 'false') { - this.enableMultiSelect(true); - } + if (layoutManager.desktop || layoutManager.mobile && this.getAttribute('data-multiselect') !== 'false') { + this.enableMultiSelect(true); } if (layoutManager.tv) { diff --git a/src/elements/emby-slider/emby-slider.js b/src/elements/emby-slider/emby-slider.js index 0bb20270e6..04a8c94cf3 100644 --- a/src/elements/emby-slider/emby-slider.js +++ b/src/elements/emby-slider/emby-slider.js @@ -443,10 +443,8 @@ import '../emby-input/emby-input'; } for (const range of ranges) { - if (position != null) { - if (position >= range.end) { - continue; - } + if (position != null && position >= range.end) { + continue; } setRange(elem, range.start, range.end); diff --git a/src/elements/emby-tabs/emby-tabs.js b/src/elements/emby-tabs/emby-tabs.js index ce1fcee05d..723cb7e8fe 100644 --- a/src/elements/emby-tabs/emby-tabs.js +++ b/src/elements/emby-tabs/emby-tabs.js @@ -272,10 +272,8 @@ import '../../assets/css/scrollstyles.scss'; let sibling = elem[method]; while (sibling) { - if (sibling.classList.contains(buttonClass)) { - if (!sibling.classList.contains('hide')) { - return sibling; - } + if (sibling.classList.contains(buttonClass) && !sibling.classList.contains('hide')) { + return sibling; } sibling = sibling[method]; diff --git a/src/index.jsx b/src/index.jsx index e177a281e1..81f3bcf43e 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -79,10 +79,10 @@ function init() { } function onGlobalizeInit() { - if (window.appMode === 'android') { - if (window.location.href.toString().toLowerCase().indexOf('start=backgroundsync') !== -1) { - return onAppReady(); - } + if (window.appMode === 'android' + && window.location.href.toString().toLowerCase().indexOf('start=backgroundsync') !== -1 + ) { + return onAppReady(); } document.title = globalize.translateHtml(document.title, 'core'); diff --git a/src/libraries/navdrawer/navdrawer.js b/src/libraries/navdrawer/navdrawer.js index 8b786ea5fe..a152c1c203 100644 --- a/src/libraries/navdrawer/navdrawer.js +++ b/src/libraries/navdrawer/navdrawer.js @@ -289,34 +289,32 @@ class NavDrawer { setEdgeSwipeEnabled(enabled) { const options = this.options; - if (!options.disableEdgeSwipe) { - if (browser.touch) { - if (enabled) { - if (!this._edgeSwipeEnabled) { - this._edgeSwipeEnabled = true; - dom.addEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, { - passive: true - }); - dom.addEventListener(this.edgeContainer, 'touchend', this.onEdgeTouchEnd, { - passive: true - }); - dom.addEventListener(this.edgeContainer, 'touchcancel', this.onEdgeTouchEnd, { - passive: true - }); - } - } else { - if (this._edgeSwipeEnabled) { - this._edgeSwipeEnabled = false; - dom.removeEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, { - passive: true - }); - dom.removeEventListener(this.edgeContainer, 'touchend', this.onEdgeTouchEnd, { - passive: true - }); - dom.removeEventListener(this.edgeContainer, 'touchcancel', this.onEdgeTouchEnd, { - passive: true - }); - } + if (!options.disableEdgeSwipe && browser.touch) { + if (enabled) { + if (!this._edgeSwipeEnabled) { + this._edgeSwipeEnabled = true; + dom.addEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, { + passive: true + }); + dom.addEventListener(this.edgeContainer, 'touchend', this.onEdgeTouchEnd, { + passive: true + }); + dom.addEventListener(this.edgeContainer, 'touchcancel', this.onEdgeTouchEnd, { + passive: true + }); + } + } else { + if (this._edgeSwipeEnabled) { + this._edgeSwipeEnabled = false; + dom.removeEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, { + passive: true + }); + dom.removeEventListener(this.edgeContainer, 'touchend', this.onEdgeTouchEnd, { + passive: true + }); + dom.removeEventListener(this.edgeContainer, 'touchcancel', this.onEdgeTouchEnd, { + passive: true + }); } } } diff --git a/src/libraries/scroller.js b/src/libraries/scroller.js index 82fb79acb2..26b4a8370b 100644 --- a/src/libraries/scroller.js +++ b/src/libraries/scroller.js @@ -279,10 +279,8 @@ const scrollerFactory = function (frame, options) { const now = new Date().getTime(); - if (o.autoImmediate) { - if (!immediate && (now - (lastAnimate || 0)) <= 50) { - immediate = true; - } + if (o.autoImmediate && !immediate && (now - (lastAnimate || 0)) <= 50) { + immediate = true; } if (!immediate && o.skipSlideToWhenVisible && fullItemPos && fullItemPos.isVisible) { @@ -787,15 +785,13 @@ const scrollerFactory = function (frame, options) { passive: true }); } - } else if (o.horizontal) { + } else if (o.horizontal && o.mouseWheel) { // Don't bind to mouse events with vertical scroll since the mouse wheel can handle this natively - if (o.mouseWheel) { - // Scrolling navigation - dom.addEventListener(scrollSource, wheelEvent, scrollHandler, { - passive: true - }); - } + // Scrolling navigation + dom.addEventListener(scrollSource, wheelEvent, scrollHandler, { + passive: true + }); } dom.addEventListener(frame, 'click', onFrameClick, { diff --git a/src/plugins/chromecastPlayer/plugin.js b/src/plugins/chromecastPlayer/plugin.js index 947426ec26..aeced81b8b 100644 --- a/src/plugins/chromecastPlayer/plugin.js +++ b/src/plugins/chromecastPlayer/plugin.js @@ -452,11 +452,9 @@ function normalizeImages(state) { if (state && state.NowPlayingItem) { const item = state.NowPlayingItem; - if (!item.ImageTags || !item.ImageTags.Primary) { - if (item.PrimaryImageTag) { - item.ImageTags = item.ImageTags || {}; - item.ImageTags.Primary = item.PrimaryImageTag; - } + if ((!item.ImageTags || !item.ImageTags.Primary) && item.PrimaryImageTag) { + item.ImageTags = item.ImageTags || {}; + item.ImageTags.Primary = item.PrimaryImageTag; } if (item.BackdropImageTag && item.BackdropItemId === item.Id) { item.BackdropImageTags = [item.BackdropImageTag]; diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index d3a893e1dd..d7ae7f7841 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -67,16 +67,12 @@ function tryRemoveElement(elem) { } function enableNativeTrackSupport(currentSrc, track) { - if (track) { - if (track.DeliveryMethod === 'Embed') { - return true; - } + if (track?.DeliveryMethod === 'Embed') { + return true; } - if (browser.firefox) { - if ((currentSrc || '').toLowerCase().includes('.m3u8')) { - return false; - } + if (browser.firefox && (currentSrc || '').toLowerCase().includes('.m3u8')) { + return false; } if (browser.ps4) { @@ -92,11 +88,9 @@ function tryRemoveElement(elem) { return false; } - if (browser.iOS) { + if (browser.iOS && (browser.iosVersion || 10) < 10) { // works in the browser but not the native app - if ((browser.iosVersion || 10) < 10) { - return false; - } + return false; } if (track) { @@ -1500,10 +1494,11 @@ function tryRemoveElement(elem) { || document.pictureInPictureEnabled ) { list.push('PictureInPicture'); - } else if (window.Windows) { - if (Windows.UI.ViewManagement.ApplicationView.getForCurrentView().isViewModeSupported(Windows.UI.ViewManagement.ApplicationViewMode.compactOverlay)) { + } else if (window.Windows + && Windows.UI.ViewManagement.ApplicationView.getForCurrentView() + .isViewModeSupported(Windows.UI.ViewManagement.ApplicationViewMode.compactOverlay) + ) { list.push('PictureInPicture'); - } } if (browser.safari || browser.iOS || browser.iPad) { @@ -1564,13 +1559,7 @@ function tryRemoveElement(elem) { } const video = this.#mediaElement; - if (video) { - if (video.audioTracks) { - return true; - } - } - - return false; + return !!video?.audioTracks; } static onPictureInPictureError(err) { diff --git a/src/plugins/sessionPlayer/plugin.js b/src/plugins/sessionPlayer/plugin.js index 6997dc1732..50c6dae8a6 100644 --- a/src/plugins/sessionPlayer/plugin.js +++ b/src/plugins/sessionPlayer/plugin.js @@ -159,11 +159,9 @@ function normalizeImages(state, apiClient) { if (state && state.NowPlayingItem) { const item = state.NowPlayingItem; - if (!item.ImageTags || !item.ImageTags.Primary) { - if (item.PrimaryImageTag) { - item.ImageTags = item.ImageTags || {}; - item.ImageTags.Primary = item.PrimaryImageTag; - } + if (!item.ImageTags || !item.ImageTags.Primary && item.PrimaryImageTag) { + item.ImageTags = item.ImageTags || {}; + item.ImageTags.Primary = item.PrimaryImageTag; } if (item.BackdropImageTag && item.BackdropItemId === item.Id) { item.BackdropImageTags = [item.BackdropImageTag]; diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index 96d23c2f37..788dbfcfb1 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -333,10 +333,8 @@ class YoutubePlayer { setVolume(val) { const currentYoutubePlayer = this.currentYoutubePlayer; - if (currentYoutubePlayer) { - if (val != null) { - currentYoutubePlayer.setVolume(val); - } + if (currentYoutubePlayer && val != null) { + currentYoutubePlayer.setVolume(val); } } getVolume() { diff --git a/src/scripts/browser.js b/src/scripts/browser.js index b340a403f3..15e5cf6627 100644 --- a/src/scripts/browser.js +++ b/src/scripts/browser.js @@ -324,11 +324,9 @@ if (browser.mobile || browser.tv) { browser.slow = true; } -if (typeof document !== 'undefined') { - /* eslint-disable-next-line compat/compat */ - if (('ontouchstart' in window) || (navigator.maxTouchPoints > 0)) { - browser.touch = true; - } +/* eslint-disable-next-line compat/compat */ +if (typeof document !== 'undefined' && ('ontouchstart' in window) || (navigator.maxTouchPoints > 0)) { + browser.touch = true; } browser.keyboard = hasKeyboard(browser); diff --git a/src/scripts/browserDeviceProfile.js b/src/scripts/browserDeviceProfile.js index 5c3b0b8ca8..9ac3c2b7eb 100644 --- a/src/scripts/browserDeviceProfile.js +++ b/src/scripts/browserDeviceProfile.js @@ -822,12 +822,12 @@ import browser from './browser'; maxH264Level = 52; } - if (browser.tizen || - videoTestElement.canPlayType('video/mp4; codecs="avc1.6e0033"').replace(/no/, '')) { + if ((browser.tizen || + videoTestElement.canPlayType('video/mp4; codecs="avc1.6e0033"').replace(/no/, '')) // These tests are passing in safari, but playback is failing - if (!browser.safari && !browser.iOS && !browser.web0s && !browser.edge && !browser.mobile) { - h264Profiles += '|high 10'; - } + && !browser.safari && !browser.iOS && !browser.web0s && !browser.edge && !browser.mobile + ) { + h264Profiles += '|high 10'; } let maxHevcLevel = 120; diff --git a/src/scripts/libraryBrowser.js b/src/scripts/libraryBrowser.js index 426b53eb45..b9fe249bd4 100644 --- a/src/scripts/libraryBrowser.js +++ b/src/scripts/libraryBrowser.js @@ -68,10 +68,8 @@ export function showLayoutMenu (button, currentLayout, views) { cancelable: false })); - if (!dispatchEvent) { - if (window.$) { - $(button).trigger('layoutchange', [id]); - } + if (!dispatchEvent && window.$) { + $(button).trigger('layoutchange', [id]); } } }); diff --git a/src/scripts/mouseManager.js b/src/scripts/mouseManager.js index 1ad3389c04..b00850a022 100644 --- a/src/scripts/mouseManager.js +++ b/src/scripts/mouseManager.js @@ -88,12 +88,10 @@ import dom from '../scripts/dom'; function onPointerEnter(e) { const pointerType = e.pointerType || (layoutManager.mobile ? 'touch' : 'mouse'); - if (pointerType === 'mouse') { - if (!isMouseIdle) { - const parent = focusManager.focusableParent(e.target); - if (parent) { - focusManager.focus(parent); - } + if (pointerType === 'mouse' && !isMouseIdle) { + const parent = focusManager.focusableParent(e.target); + if (parent) { + focusManager.focus(parent); } } }