From aef99ce247d927ead97d07d2d9c389839e945d6d Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Tue, 12 Sep 2023 17:01:34 -0400 Subject: [PATCH 1/2] Add eslint rule to prevent "lonely" if statements --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index 44fd0a3046..cbf9bfda79 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -48,6 +48,7 @@ module.exports = { 'no-empty-function': ['error'], 'no-extend-native': ['error'], 'no-floating-decimal': ['error'], + 'no-lonely-if': ['error'], 'no-multi-spaces': ['error'], 'no-multiple-empty-lines': ['error', { 'max': 1 }], 'no-nested-ternary': ['error'], From 20381bd3ec2f23907ed53d7da568cae921b05506 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Tue, 12 Sep 2023 17:02:06 -0400 Subject: [PATCH 2/2] Fix all loneliness --- src/components/cardbuilder/cardBuilder.js | 30 +++++------ src/components/guide/guide.js | 8 ++- src/components/homesections/homesections.js | 12 ++--- src/components/htmlMediaHelper.js | 22 ++++---- .../imageDownloader/imageDownloader.js | 32 +++++------- src/components/imageeditor/imageeditor.js | 6 +-- src/components/listview/listview.js | 14 +++-- src/components/nowPlayingBar/nowPlayingBar.js | 6 +-- src/components/playback/playbackmanager.js | 14 +++-- .../recordingcreator/recordingfields.js | 28 +++++----- src/components/viewContainer.js | 8 ++- src/controllers/dashboard/dashboard.js | 12 ++--- src/controllers/dashboard/dlna/profile.js | 18 +++---- src/controllers/playback/video/index.js | 8 ++- .../emby-itemscontainer.js | 6 +-- src/index.jsx | 6 +-- src/libraries/navdrawer/navdrawer.js | 52 ++++++++----------- src/libraries/scroller.js | 18 +++---- src/plugins/htmlVideoPlayer/plugin.js | 27 ++++------ src/plugins/youtubePlayer/plugin.js | 6 +-- src/scripts/libraryMenu.js | 28 +++++----- src/scripts/scrollHelper.js | 16 +++--- 22 files changed, 154 insertions(+), 223 deletions(-) diff --git a/src/components/cardbuilder/cardBuilder.js b/src/components/cardbuilder/cardBuilder.js index d5b19c0210..96d7edb06a 100644 --- a/src/components/cardbuilder/cardBuilder.js +++ b/src/components/cardbuilder/cardBuilder.js @@ -803,19 +803,17 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml, } 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)); } } } @@ -898,13 +896,11 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml, if (item.Type === 'Series') { if (item.Status === 'Continuing') { lines.push(globalize.translate('SeriesYearToPresent', productionYear || '')); + } else if (item.EndDate && item.ProductionYear) { + const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false }); + lines.push(productionYear + ((endYear === item.ProductionYear) ? '' : (' - ' + endYear))); } else { - if (item.EndDate && item.ProductionYear) { - const endYear = datetime.toLocaleString(datetime.parseISO8601Date(item.EndDate).getFullYear(), { useGrouping: false }); - lines.push(productionYear + ((endYear === item.ProductionYear) ? '' : (' - ' + endYear))); - } else { - lines.push(productionYear || ''); - } + lines.push(productionYear || ''); } } else { lines.push(productionYear || ''); diff --git a/src/components/guide/guide.js b/src/components/guide/guide.js index 9384ba2056..76c54693f9 100644 --- a/src/components/guide/guide.js +++ b/src/components/guide/guide.js @@ -762,12 +762,10 @@ function Guide(options) { } else { container.scrollTo(0, pos); } + } else if (horizontal) { + container.scrollLeft = Math.round(pos); } else { - if (horizontal) { - container.scrollLeft = Math.round(pos); - } else { - container.scrollTop = Math.round(pos); - } + container.scrollTop = Math.round(pos); } } diff --git a/src/components/homesections/homesections.js b/src/components/homesections/homesections.js index 2bb9bb7928..1b26f8624a 100644 --- a/src/components/homesections/homesections.js +++ b/src/components/homesections/homesections.js @@ -216,14 +216,12 @@ function getFetchLatestItemsFn(serverId, parentId, collectionType) { if (collectionType === 'music') { limit = 30; } + } else if (collectionType === 'tvshows') { + limit = 5; + } else if (collectionType === 'music') { + limit = 9; } else { - if (collectionType === 'tvshows') { - limit = 5; - } else if (collectionType === 'music') { - limit = 9; - } else { - limit = 8; - } + limit = 8; } const options = { diff --git a/src/components/htmlMediaHelper.js b/src/components/htmlMediaHelper.js index 5db0428cda..c63eb29db0 100644 --- a/src/components/htmlMediaHelper.js +++ b/src/components/htmlMediaHelper.js @@ -76,20 +76,18 @@ export function handleHlsJsMediaError(instance, reject) { recoverDecodingErrorDate = now; console.debug('try to recover media Error ...'); hlsPlayer.recoverMediaError(); + } else if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) { + recoverSwapAudioCodecDate = now; + console.debug('try to swap Audio Codec and recover media Error ...'); + hlsPlayer.swapAudioCodec(); + hlsPlayer.recoverMediaError(); } else { - if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) { - recoverSwapAudioCodecDate = now; - console.debug('try to swap Audio Codec and recover media Error ...'); - hlsPlayer.swapAudioCodec(); - hlsPlayer.recoverMediaError(); - } else { - console.error('cannot recover, last media error recovery failed ...'); + console.error('cannot recover, last media error recovery failed ...'); - if (reject) { - reject(); - } else { - onErrorInternal(instance, 'mediadecodeerror'); - } + if (reject) { + reject(); + } else { + onErrorInternal(instance, 'mediadecodeerror'); } } } diff --git a/src/components/imageDownloader/imageDownloader.js b/src/components/imageDownloader/imageDownloader.js index 1955896180..380803d664 100644 --- a/src/components/imageDownloader/imageDownloader.js +++ b/src/components/imageDownloader/imageDownloader.js @@ -171,14 +171,12 @@ function getRemoteImageHtml(image, imageType) { shape = 'banner'; } else if (imageType === 'Disc') { shape = 'square'; + } else if (currentItemType === 'Episode') { + shape = 'backdrop'; + } else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') { + shape = 'square'; } else { - if (currentItemType === 'Episode') { - shape = 'backdrop'; - } else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') { - shape = 'square'; - } else { - shape = 'portrait'; - } + shape = 'portrait'; } cssClass += ' ' + shape + 'Card ' + shape + 'Card-scalable'; @@ -230,10 +228,8 @@ function getRemoteImageHtml(image, imageType) { if (image.Language) { html += ' • ' + image.Language; } - } else { - if (image.Language) { - html += image.Language; - } + } else if (image.Language) { + html += image.Language; } html += ''; @@ -244,16 +240,14 @@ function getRemoteImageHtml(image, imageType) { if (image.RatingType === 'Likes') { html += image.CommunityRating + (image.CommunityRating === 1 ? ' like' : ' likes'); - } else { - if (image.CommunityRating) { - html += image.CommunityRating.toFixed(1); + } else if (image.CommunityRating) { + html += image.CommunityRating.toFixed(1); - if (image.VoteCount) { - html += ' • ' + image.VoteCount + (image.VoteCount === 1 ? ' vote' : ' votes'); - } - } else { - html += 'Unrated'; + if (image.VoteCount) { + html += ' • ' + image.VoteCount + (image.VoteCount === 1 ? ' vote' : ' votes'); } + } else { + html += 'Unrated'; } html += ''; diff --git a/src/components/imageeditor/imageeditor.js b/src/components/imageeditor/imageeditor.js index 6a7982cca9..9e7a9d5710 100644 --- a/src/components/imageeditor/imageeditor.js +++ b/src/components/imageeditor/imageeditor.js @@ -164,10 +164,8 @@ function getCardHtml(image, apiClient, options) { } else { html += ''; } - } else { - if (options.imageProviders.length) { - html += ''; - } + } else if (options.imageProviders.length) { + html += ''; } html += ''; diff --git a/src/components/listview/listview.js b/src/components/listview/listview.js index d35bdc3527..1a230c31ed 100644 --- a/src/components/listview/listview.js +++ b/src/components/listview/listview.js @@ -374,14 +374,12 @@ export function getListViewHtml(options) { if (options.artist !== false && item.AlbumArtist && item.Type === 'MusicAlbum') { textlines.push(item.AlbumArtist); } - } else { - if (options.artist) { - const artistItems = item.ArtistItems; - if (artistItems && item.Type !== 'MusicAlbum') { - textlines.push(artistItems.map(a => { - return a.Name; - }).join(', ')); - } + } else if (options.artist) { + const artistItems = item.ArtistItems; + if (artistItems && item.Type !== 'MusicAlbum') { + textlines.push(artistItems.map(a => { + return a.Name; + }).join(', ')); } } diff --git a/src/components/nowPlayingBar/nowPlayingBar.js b/src/components/nowPlayingBar/nowPlayingBar.js index 37400559f2..fec43db3e8 100644 --- a/src/components/nowPlayingBar/nowPlayingBar.js +++ b/src/components/nowPlayingBar/nowPlayingBar.js @@ -649,10 +649,8 @@ function onPlaybackStopped(e, state) { if (state.NextMediaType !== 'Audio') { hideNowPlayingBar(); } - } else { - if (!state.NextMediaType) { - hideNowPlayingBar(); - } + } else if (!state.NextMediaType) { + hideNowPlayingBar(); } } diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index 308acd79f5..26548bee3f 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -1437,15 +1437,13 @@ class PlaybackManager { if (Screenfull.isEnabled) { Screenfull.toggle(); - } else { + } else if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { // iOS Safari - if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { - document.webkitCancelFullscreen(); - } else { - const elem = document.querySelector('video'); - if (elem?.webkitEnterFullscreen) { - elem.webkitEnterFullscreen(); - } + document.webkitCancelFullscreen(); + } else { + const elem = document.querySelector('video'); + if (elem?.webkitEnterFullscreen) { + elem.webkitEnterFullscreen(); } } }; diff --git a/src/components/recordingcreator/recordingfields.js b/src/components/recordingcreator/recordingfields.js index d890148c3b..2fb9764f2b 100644 --- a/src/components/recordingcreator/recordingfields.js +++ b/src/components/recordingcreator/recordingfields.js @@ -191,15 +191,13 @@ function onRecordChange(e) { loading.hide(); }); } - } else { - if (hasEnabledTimer) { - loading.show(); - recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () { - Events.trigger(self, 'recordingchanged'); - fetchData(self); - loading.hide(); - }); - } + } else if (hasEnabledTimer) { + loading.show(); + recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () { + Events.trigger(self, 'recordingchanged'); + fetchData(self); + loading.hide(); + }); } } @@ -223,13 +221,11 @@ function onRecordSeriesChange(e) { fetchData(self); }); } - } else { - if (this.SeriesTimerId) { - apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () { - toast(globalize.translate('RecordingCancelled')); - fetchData(self); - }); - } + } else if (this.SeriesTimerId) { + apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () { + toast(globalize.translate('RecordingCancelled')); + fetchData(self); + }); } } diff --git a/src/components/viewContainer.js b/src/components/viewContainer.js index a5547517a7..c2156a7d58 100644 --- a/src/components/viewContainer.js +++ b/src/components/viewContainer.js @@ -73,12 +73,10 @@ export function loadView(options) { } else { mainAnimatedPages.replaceChild(view, currentPage); } + } else if (newViewInfo.hasScript && window.$) { + view = $(view).appendTo(mainAnimatedPages)[0]; } else { - if (newViewInfo.hasScript && window.$) { - view = $(view).appendTo(mainAnimatedPages)[0]; - } else { - mainAnimatedPages.appendChild(view); - } + mainAnimatedPages.appendChild(view); } if (options.type) { diff --git a/src/controllers/dashboard/dashboard.js b/src/controllers/dashboard/dashboard.js index 372000a685..bae3880f28 100644 --- a/src/controllers/dashboard/dashboard.js +++ b/src/controllers/dashboard/dashboard.js @@ -484,13 +484,11 @@ window.DashboardPage = { if (nowPlayingItem.Artists?.length) { bottomText = topText; topText = escapeHtml(nowPlayingItem.Artists[0]); - } else { - if (nowPlayingItem.SeriesName || nowPlayingItem.Album) { - bottomText = topText; - topText = escapeHtml(nowPlayingItem.SeriesName || nowPlayingItem.Album); - } else if (nowPlayingItem.ProductionYear) { - bottomText = nowPlayingItem.ProductionYear; - } + } else if (nowPlayingItem.SeriesName || nowPlayingItem.Album) { + bottomText = topText; + topText = escapeHtml(nowPlayingItem.SeriesName || nowPlayingItem.Album); + } else if (nowPlayingItem.ProductionYear) { + bottomText = nowPlayingItem.ProductionYear; } if (nowPlayingItem.ImageTags?.Logo) { diff --git a/src/controllers/dashboard/dlna/profile.js b/src/controllers/dashboard/dlna/profile.js index 47583f2510..0a88f4214e 100644 --- a/src/controllers/dashboard/dlna/profile.js +++ b/src/controllers/dashboard/dlna/profile.js @@ -272,10 +272,8 @@ function renderDirectPlayProfiles(page, profiles) { if (profile.Type == 'Video') { html += '

' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '

'; html += '

' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '

'; - } else { - if (profile.Type == 'Audio') { - html += '

' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '

'; - } + } else if (profile.Type == 'Audio') { + html += '

' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '

'; } html += ''; @@ -333,10 +331,8 @@ function renderTranscodingProfiles(page, profiles) { if (profile.Type == 'Video') { html += '

' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '

'; html += '

' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '

'; - } else { - if (profile.Type == 'Audio') { - html += '

' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '

'; - } + } else if (profile.Type == 'Audio') { + html += '

' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '

'; } html += ''; @@ -561,10 +557,8 @@ function renderResponseProfiles(page, profiles) { if (profile.Type == 'Video') { html += '

' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '

'; html += '

' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '

'; - } else { - if (profile.Type == 'Audio') { - html += '

' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '

'; - } + } else if (profile.Type == 'Audio') { + html += '

' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '

'; } if (profile.Conditions?.length) { diff --git a/src/controllers/playback/video/index.js b/src/controllers/playback/video/index.js index 0feb6e3752..ba066f1333 100644 --- a/src/controllers/playback/video/index.js +++ b/src/controllers/playback/video/index.js @@ -392,11 +392,9 @@ export default function (view) { case 'left': if (currentVisibleMenu === 'osd') { showOsd(); - } else { - if (!currentVisibleMenu) { - e.preventDefault(); - playbackManager.rewind(player); - } + } else if (!currentVisibleMenu) { + e.preventDefault(); + playbackManager.rewind(player); } break; diff --git a/src/elements/emby-itemscontainer/emby-itemscontainer.js b/src/elements/emby-itemscontainer/emby-itemscontainer.js index b951fa7d2f..dd40a80531 100644 --- a/src/elements/emby-itemscontainer/emby-itemscontainer.js +++ b/src/elements/emby-itemscontainer/emby-itemscontainer.js @@ -285,10 +285,8 @@ ItemsContainerPrototype.attachedCallback = function () { if (browser.touch) { this.addEventListener('contextmenu', disableEvent); - } else { - if (this.getAttribute('data-contextmenu') !== 'false') { - this.addEventListener('contextmenu', onContextMenu); - } + } else if (this.getAttribute('data-contextmenu') !== 'false') { + this.addEventListener('contextmenu', onContextMenu); } if (layoutManager.desktop || layoutManager.mobile && this.getAttribute('data-multiselect') !== 'false') { diff --git a/src/index.jsx b/src/index.jsx index 9bcbffa05c..49d95c56c6 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -227,10 +227,8 @@ async function onAppReady() { document.body.appendChild(localStyle); } localStyle.textContent = localCss; - } else { - if (localStyle) { - localStyle.textContent = ''; - } + } else if (localStyle) { + localStyle.textContent = ''; } }; diff --git a/src/libraries/navdrawer/navdrawer.js b/src/libraries/navdrawer/navdrawer.js index ef6dd1e04f..9bd33b5edf 100644 --- a/src/libraries/navdrawer/navdrawer.js +++ b/src/libraries/navdrawer/navdrawer.js @@ -130,17 +130,15 @@ class NavDrawer { if (this.isPeeking) { this.onMenuTouchMove(e); - } else { - if ((getTouches(e)[0]?.clientX || 0) <= options.handleSize) { - this.isPeeking = true; + } else if ((getTouches(e)[0]?.clientX || 0) <= options.handleSize) { + this.isPeeking = true; - if (e.type === 'touchstart') { - dom.removeEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {}); - dom.addEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {}); - } - - this.onMenuTouchStart(e); + if (e.type === 'touchstart') { + dom.removeEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {}); + dom.addEventListener(this.edgeContainer, 'touchmove', this.onEdgeTouchMove, {}); } + + this.onMenuTouchStart(e); } }; @@ -246,14 +244,10 @@ class NavDrawer { } else { this.close(); } - } else { - if (this.newPos >= 100) { - this.open(); - } else { - if (this.newPos) { - this.close(); - } - } + } else if (this.newPos >= 100) { + this.open(); + } else if (this.newPos) { + this.close(); } } @@ -320,19 +314,17 @@ class NavDrawer { 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 - }); - } + } 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 12edc468cc..7e72141864 100644 --- a/src/libraries/scroller.js +++ b/src/libraries/scroller.js @@ -257,12 +257,10 @@ const scrollerFactory = function (frame, options) { } else { container.scrollTo(0, Math.round(pos)); } + } else if (o.horizontal) { + container.scrollLeft = Math.round(pos); } else { - if (o.horizontal) { - container.scrollLeft = Math.round(pos); - } else { - container.scrollTop = Math.round(pos); - } + container.scrollTop = Math.round(pos); } } @@ -506,14 +504,12 @@ const scrollerFactory = function (frame, options) { // If the pointer was released, the path will not become longer and it's // definitely not a drag. If not released yet, decide on next iteration return dragging.released ? dragEnd() : undefined; - } else { + } else if (o.horizontal ? Math.abs(dragging.pathX) > Math.abs(dragging.pathY) : Math.abs(dragging.pathX) < Math.abs(dragging.pathY)) { // If dragging path is sufficiently long we can confidently start a drag // if drag is in different direction than scroll, ignore it - if (o.horizontal ? Math.abs(dragging.pathX) > Math.abs(dragging.pathY) : Math.abs(dragging.pathX) < Math.abs(dragging.pathY)) { - dragging.init = 1; - } else { - return dragEnd(); - } + dragging.init = 1; + } else { + return dragEnd(); } } diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index c6d9eeb68b..a3d9420c6e 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -864,11 +864,9 @@ export class HtmlVideoPlayer { if (Screenfull.isEnabled) { Screenfull.exit(); - } else { + } else if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { // iOS Safari - if (document.webkitIsFullScreen && document.webkitCancelFullscreen) { - document.webkitCancelFullscreen(); - } + document.webkitCancelFullscreen(); } } @@ -1106,15 +1104,14 @@ export class HtmlVideoPlayer { tryRemoveElement(this.#videoSecondarySubtitlesElem); this.#videoSecondarySubtitlesElem = null; } - } else { // destroy all - if (this.#videoSubtitlesElem) { - const subtitlesContainer = this.#videoSubtitlesElem.parentNode; - if (subtitlesContainer) { - tryRemoveElement(subtitlesContainer); - } - this.#videoSubtitlesElem = null; - this.#videoSecondarySubtitlesElem = null; + } else if (this.#videoSubtitlesElem) { + // destroy all + const subtitlesContainer = this.#videoSubtitlesElem.parentNode; + if (subtitlesContainer) { + tryRemoveElement(subtitlesContainer); } + this.#videoSubtitlesElem = null; + this.#videoSecondarySubtitlesElem = null; } } @@ -1812,10 +1809,8 @@ export class HtmlVideoPlayer { } else { Windows.UI.ViewManagement.ApplicationView.getForCurrentView().tryEnterViewModeAsync(Windows.UI.ViewManagement.ApplicationViewMode.default); } - } else { - if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') { - video.webkitSetPresentationMode(isEnabled ? 'picture-in-picture' : 'inline'); - } + } else if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') { + video.webkitSetPresentationMode(isEnabled ? 'picture-in-picture' : 'inline'); } } diff --git a/src/plugins/youtubePlayer/plugin.js b/src/plugins/youtubePlayer/plugin.js index 47492468aa..7c9b68cd95 100644 --- a/src/plugins/youtubePlayer/plugin.js +++ b/src/plugins/youtubePlayer/plugin.js @@ -352,10 +352,8 @@ class YoutubePlayer { if (currentYoutubePlayer) { currentYoutubePlayer.mute(); } - } else { - if (currentYoutubePlayer) { - currentYoutubePlayer.unMute(); - } + } else if (currentYoutubePlayer) { + currentYoutubePlayer.unMute(); } } isMuted() { diff --git a/src/scripts/libraryMenu.js b/src/scripts/libraryMenu.js index b77dfa92e1..0f3b4a73e1 100644 --- a/src/scripts/libraryMenu.js +++ b/src/scripts/libraryMenu.js @@ -835,26 +835,24 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) { bodyClassList.remove('dashboardDocument'); bodyClassList.remove('hideMainDrawer'); + if (navDrawerInstance) { + navDrawerInstance.setEdgeSwipeEnabled(true); + } + } else if (isDashboardPage) { + bodyClassList.remove('libraryDocument'); + bodyClassList.add('dashboardDocument'); + bodyClassList.remove('hideMainDrawer'); + if (navDrawerInstance) { navDrawerInstance.setEdgeSwipeEnabled(true); } } else { - if (isDashboardPage) { - bodyClassList.remove('libraryDocument'); - bodyClassList.add('dashboardDocument'); - bodyClassList.remove('hideMainDrawer'); + bodyClassList.remove('libraryDocument'); + bodyClassList.remove('dashboardDocument'); + bodyClassList.add('hideMainDrawer'); - if (navDrawerInstance) { - navDrawerInstance.setEdgeSwipeEnabled(true); - } - } else { - bodyClassList.remove('libraryDocument'); - bodyClassList.remove('dashboardDocument'); - bodyClassList.add('hideMainDrawer'); - - if (navDrawerInstance) { - navDrawerInstance.setEdgeSwipeEnabled(false); - } + if (navDrawerInstance) { + navDrawerInstance.setEdgeSwipeEnabled(false); } } } diff --git a/src/scripts/scrollHelper.js b/src/scripts/scrollHelper.js index 725df86434..9f6a870ed3 100644 --- a/src/scripts/scrollHelper.js +++ b/src/scripts/scrollHelper.js @@ -54,12 +54,10 @@ export function toCenter(container, elem, horizontal, skipWhenVisible) { } else { container.scrollTo(0, pos.center); } + } else if (horizontal) { + container.scrollLeft = Math.round(pos.center); } else { - if (horizontal) { - container.scrollLeft = Math.round(pos.center); - } else { - container.scrollTop = Math.round(pos.center); - } + container.scrollTop = Math.round(pos.center); } } @@ -76,12 +74,10 @@ export function toStart(container, elem, horizontal, skipWhenVisible) { } else { container.scrollTo(0, pos.start); } + } else if (horizontal) { + container.scrollLeft = Math.round(pos.start); } else { - if (horizontal) { - container.scrollLeft = Math.round(pos.start); - } else { - container.scrollTop = Math.round(pos.start); - } + container.scrollTop = Math.round(pos.start); } }