Merge pull request #4774 from thornbill/owner-of-a-lonely-if

This commit is contained in:
Bill Thornton 2023-09-14 10:53:21 -04:00 committed by GitHub
commit bb44ba022d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 155 additions and 223 deletions

View File

@ -49,6 +49,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'],

View File

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

View File

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

View File

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

View File

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

View File

@ -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 += '</div>';
@ -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 += '</div>';

View File

@ -164,10 +164,8 @@ function getCardHtml(image, apiClient, options) {
} else {
html += '<button type="button" is="paper-icon-button-light" class="autoSize" disabled title="' + globalize.translate('MoveRight') + '"><span class="material-icons chevron_right" aria-hidden="true"></span></button>';
}
} else {
if (options.imageProviders.length) {
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('Search') + '"><span class="material-icons search" aria-hidden="true"></span></button>';
}
} else if (options.imageProviders.length) {
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" class="btnSearchImages autoSize" title="' + globalize.translate('Search') + '"><span class="material-icons search" aria-hidden="true"></span></button>';
}
html += '<button type="button" is="paper-icon-button-light" data-imagetype="' + image.ImageType + '" data-index="' + (image.ImageIndex != null ? image.ImageIndex : 'null') + '" class="btnDeleteImage autoSize" title="' + globalize.translate('Delete') + '"><span class="material-icons delete" aria-hidden="true"></span></button>';

View File

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

View File

@ -649,10 +649,8 @@ function onPlaybackStopped(e, state) {
if (state.NextMediaType !== 'Audio') {
hideNowPlayingBar();
}
} else {
if (!state.NextMediaType) {
hideNowPlayingBar();
}
} else if (!state.NextMediaType) {
hideNowPlayingBar();
}
}

View File

@ -1416,15 +1416,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();
}
}
};

View File

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

View File

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

View File

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

View File

@ -272,10 +272,8 @@ function renderDirectPlayProfiles(page, profiles) {
if (profile.Type == 'Video') {
html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>';
} else {
if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
} else if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
html += '</a>';
@ -333,10 +331,8 @@ function renderTranscodingProfiles(page, profiles) {
if (profile.Type == 'Video') {
html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>';
} else {
if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
} else if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
html += '</a>';
@ -561,10 +557,8 @@ function renderResponseProfiles(page, profiles) {
if (profile.Type == 'Video') {
html += '<p>' + globalize.translate('ValueVideoCodec', profile.VideoCodec || allText) + '</p>';
html += '<p>' + globalize.translate('ValueAudioCodec', profile.AudioCodec || allText) + '</p>';
} else {
if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
} else if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
if (profile.Conditions?.length) {

View File

@ -391,11 +391,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;

View File

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

View File

@ -227,10 +227,8 @@ async function onAppReady() {
document.body.appendChild(localStyle);
}
localStyle.textContent = localCss;
} else {
if (localStyle) {
localStyle.textContent = '';
}
} else if (localStyle) {
localStyle.textContent = '';
}
};

View File

@ -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);
}
};
@ -247,14 +245,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();
}
}
@ -321,19 +315,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
});
}
}
}

View File

@ -258,12 +258,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);
}
}
@ -507,14 +505,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();
}
}

View File

@ -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;
}
}
@ -1818,10 +1815,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');
}
}

View File

@ -352,10 +352,8 @@ class YoutubePlayer {
if (currentYoutubePlayer) {
currentYoutubePlayer.mute();
}
} else {
if (currentYoutubePlayer) {
currentYoutubePlayer.unMute();
}
} else if (currentYoutubePlayer) {
currentYoutubePlayer.unMute();
}
}
isMuted() {

View File

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

View File

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