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,8 +803,7 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
} else {
lines.push(escapeHtml(item.SeriesName));
}
} else {
if (isUsingLiveTvNaming(item)) {
} else if (isUsingLiveTvNaming(item)) {
lines.push(escapeHtml(item.Name));
if (!item.EpisodeTitle && !item.IndexNumber) {
@ -818,7 +817,6 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
}
}
}
}
let showMediaTitle = (showTitle && !titleAdded) || (options.showParentTitleOrTitle && !lines.length);
if (!showMediaTitle && !titleAdded && (showTitle || flags.forceName)) {
@ -898,14 +896,12 @@ 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) {
} 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 || '');
}
}
} else {
lines.push(productionYear || '');
}

View File

@ -762,14 +762,12 @@ function Guide(options) {
} else {
container.scrollTo(0, pos);
}
} else {
if (horizontal) {
} else if (horizontal) {
container.scrollLeft = Math.round(pos);
} else {
container.scrollTop = Math.round(pos);
}
}
}
let lastGridScroll = 0;
let lastHeaderScroll = 0;

View File

@ -216,15 +216,13 @@ function getFetchLatestItemsFn(serverId, parentId, collectionType) {
if (collectionType === 'music') {
limit = 30;
}
} else {
if (collectionType === 'tvshows') {
} else if (collectionType === 'tvshows') {
limit = 5;
} else if (collectionType === 'music') {
limit = 9;
} else {
limit = 8;
}
}
const options = {
Limit: limit,

View File

@ -76,8 +76,7 @@ export function handleHlsJsMediaError(instance, reject) {
recoverDecodingErrorDate = now;
console.debug('try to recover media Error ...');
hlsPlayer.recoverMediaError();
} else {
if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) {
} else if (!recoverSwapAudioCodecDate || (now - recoverSwapAudioCodecDate) > 3000) {
recoverSwapAudioCodecDate = now;
console.debug('try to swap Audio Codec and recover media Error ...');
hlsPlayer.swapAudioCodec();
@ -92,7 +91,6 @@ export function handleHlsJsMediaError(instance, reject) {
}
}
}
}
export function onErrorInternal(instance, type) {
// Needed for video

View File

@ -171,15 +171,13 @@ function getRemoteImageHtml(image, imageType) {
shape = 'banner';
} else if (imageType === 'Disc') {
shape = 'square';
} else {
if (currentItemType === 'Episode') {
} else if (currentItemType === 'Episode') {
shape = 'backdrop';
} else if (currentItemType === 'MusicAlbum' || currentItemType === 'MusicArtist') {
shape = 'square';
} else {
shape = 'portrait';
}
}
cssClass += ' ' + shape + 'Card ' + shape + 'Card-scalable';
if (tagName === 'button') {
@ -230,11 +228,9 @@ function getRemoteImageHtml(image, imageType) {
if (image.Language) {
html += ' • ' + image.Language;
}
} else {
if (image.Language) {
} else if (image.Language) {
html += image.Language;
}
}
html += '</div>';
}
@ -244,8 +240,7 @@ function getRemoteImageHtml(image, imageType) {
if (image.RatingType === 'Likes') {
html += image.CommunityRating + (image.CommunityRating === 1 ? ' like' : ' likes');
} else {
if (image.CommunityRating) {
} else if (image.CommunityRating) {
html += image.CommunityRating.toFixed(1);
if (image.VoteCount) {
@ -254,7 +249,6 @@ function getRemoteImageHtml(image, imageType) {
} else {
html += 'Unrated';
}
}
html += '</div>';
}

View File

@ -164,11 +164,9 @@ 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) {
} 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>';
html += '</div>';

View File

@ -374,8 +374,7 @@ export function getListViewHtml(options) {
if (options.artist !== false && item.AlbumArtist && item.Type === 'MusicAlbum') {
textlines.push(item.AlbumArtist);
}
} else {
if (options.artist) {
} else if (options.artist) {
const artistItems = item.ArtistItems;
if (artistItems && item.Type !== 'MusicAlbum') {
textlines.push(artistItems.map(a => {
@ -383,7 +382,6 @@ export function getListViewHtml(options) {
}).join(', '));
}
}
}
if (item.Type === 'TvChannel' && item.CurrentProgram) {
textlines.push(itemHelper.getDisplayName(item.CurrentProgram));

View File

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

View File

@ -1416,9 +1416,8 @@ 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');
@ -1426,7 +1425,6 @@ class PlaybackManager {
elem.webkitEnterFullscreen();
}
}
}
};
self.togglePictureInPicture = function (player) {

View File

@ -191,8 +191,7 @@ function onRecordChange(e) {
loading.hide();
});
}
} else {
if (hasEnabledTimer) {
} else if (hasEnabledTimer) {
loading.show();
recordingHelper.cancelTimer(apiClient, this.TimerId, true).then(function () {
Events.trigger(self, 'recordingchanged');
@ -201,7 +200,6 @@ function onRecordChange(e) {
});
}
}
}
function onRecordSeriesChange(e) {
this.changed = true;
@ -223,14 +221,12 @@ function onRecordSeriesChange(e) {
fetchData(self);
});
}
} else {
if (this.SeriesTimerId) {
} else if (this.SeriesTimerId) {
apiClient.cancelLiveTvSeriesTimer(this.SeriesTimerId).then(function () {
toast(globalize.translate('RecordingCancelled'));
fetchData(self);
});
}
}
}
export default RecordingEditor;

View File

@ -73,13 +73,11 @@ export function loadView(options) {
} else {
mainAnimatedPages.replaceChild(view, currentPage);
}
} else {
if (newViewInfo.hasScript && window.$) {
} else if (newViewInfo.hasScript && window.$) {
view = $(view).appendTo(mainAnimatedPages)[0];
} else {
mainAnimatedPages.appendChild(view);
}
}
if (options.type) {
view.setAttribute('data-type', options.type);

View File

@ -484,14 +484,12 @@ window.DashboardPage = {
if (nowPlayingItem.Artists?.length) {
bottomText = topText;
topText = escapeHtml(nowPlayingItem.Artists[0]);
} else {
if (nowPlayingItem.SeriesName || nowPlayingItem.Album) {
} 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) {
imgUrl = ApiClient.getScaledImageUrl(nowPlayingItem.Id, {

View File

@ -272,11 +272,9 @@ 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') {
} else if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
}
html += '</a>';
html += '<button type="button" is="paper-icon-button-light" class="btnDeleteProfile listItemButton" data-profileindex="' + index + '"><span class="material-icons delete" aria-hidden="true"></span></button>';
@ -333,11 +331,9 @@ 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') {
} else if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
}
html += '</a>';
html += '<button type="button" is="paper-icon-button-light" class="btnDeleteProfile listItemButton" data-profileindex="' + i + '"><span class="material-icons delete" aria-hidden="true"></span></button>';
@ -561,11 +557,9 @@ 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') {
} else if (profile.Type == 'Audio') {
html += '<p>' + globalize.translate('ValueCodec', profile.AudioCodec || allText) + '</p>';
}
}
if (profile.Conditions?.length) {
html += '<p>';

View File

@ -391,12 +391,10 @@ export default function (view) {
case 'left':
if (currentVisibleMenu === 'osd') {
showOsd();
} else {
if (!currentVisibleMenu) {
} else if (!currentVisibleMenu) {
e.preventDefault();
playbackManager.rewind(player);
}
}
break;

View File

@ -285,11 +285,9 @@ ItemsContainerPrototype.attachedCallback = function () {
if (browser.touch) {
this.addEventListener('contextmenu', disableEvent);
} else {
if (this.getAttribute('data-contextmenu') !== 'false') {
} else if (this.getAttribute('data-contextmenu') !== 'false') {
this.addEventListener('contextmenu', onContextMenu);
}
}
if (layoutManager.desktop || layoutManager.mobile && this.getAttribute('data-multiselect') !== 'false') {
this.enableMultiSelect(true);

View File

@ -227,11 +227,9 @@ async function onAppReady() {
document.body.appendChild(localStyle);
}
localStyle.textContent = localCss;
} else {
if (localStyle) {
} else if (localStyle) {
localStyle.textContent = '';
}
}
};
const handleUserChange = () => {

View File

@ -130,8 +130,7 @@ class NavDrawer {
if (this.isPeeking) {
this.onMenuTouchMove(e);
} else {
if ((getTouches(e)[0]?.clientX || 0) <= options.handleSize) {
} else if ((getTouches(e)[0]?.clientX || 0) <= options.handleSize) {
this.isPeeking = true;
if (e.type === 'touchstart') {
@ -141,7 +140,6 @@ class NavDrawer {
this.onMenuTouchStart(e);
}
}
};
onEdgeTouchEnd = (e) => {
@ -247,16 +245,12 @@ class NavDrawer {
} else {
this.close();
}
} else {
if (this.newPos >= 100) {
} else if (this.newPos >= 100) {
this.open();
} else {
if (this.newPos) {
} else if (this.newPos) {
this.close();
}
}
}
}
open() {
const options = this.options;
@ -321,8 +315,7 @@ class NavDrawer {
passive: true
});
}
} else {
if (this._edgeSwipeEnabled) {
} else if (this._edgeSwipeEnabled) {
this._edgeSwipeEnabled = false;
dom.removeEventListener(this.edgeContainer, 'touchstart', this.onEdgeTouchStart, {
passive: true
@ -336,7 +329,6 @@ class NavDrawer {
}
}
}
}
initialize() {
const options = Object.assign({}, this.defaults, this.options || {});

View File

@ -258,14 +258,12 @@ const scrollerFactory = function (frame, options) {
} else {
container.scrollTo(0, Math.round(pos));
}
} else {
if (o.horizontal) {
} else if (o.horizontal) {
container.scrollLeft = Math.round(pos);
} else {
container.scrollTop = Math.round(pos);
}
}
}
let lastAnimate;
@ -507,16 +505,14 @@ 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();
}
}
}
// Disable click on a source element, as it is unwelcome when dragging
if (!dragging.locked && dragging.path > dragging.pathToLock) {

View File

@ -864,13 +864,11 @@ export class HtmlVideoPlayer {
if (Screenfull.isEnabled) {
Screenfull.exit();
} else {
} else if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
// iOS Safari
if (document.webkitIsFullScreen && document.webkitCancelFullscreen) {
document.webkitCancelFullscreen();
}
}
}
/**
* @private
@ -1106,8 +1104,8 @@ export class HtmlVideoPlayer {
tryRemoveElement(this.#videoSecondarySubtitlesElem);
this.#videoSecondarySubtitlesElem = null;
}
} else { // destroy all
if (this.#videoSubtitlesElem) {
} else if (this.#videoSubtitlesElem) {
// destroy all
const subtitlesContainer = this.#videoSubtitlesElem.parentNode;
if (subtitlesContainer) {
tryRemoveElement(subtitlesContainer);
@ -1116,7 +1114,6 @@ export class HtmlVideoPlayer {
this.#videoSecondarySubtitlesElem = null;
}
}
}
/**
* @private
@ -1818,12 +1815,10 @@ export class HtmlVideoPlayer {
} else {
Windows.UI.ViewManagement.ApplicationView.getForCurrentView().tryEnterViewModeAsync(Windows.UI.ViewManagement.ApplicationViewMode.default);
}
} else {
if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') {
} else if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') {
video.webkitSetPresentationMode(isEnabled ? 'picture-in-picture' : 'inline');
}
}
}
isPictureInPictureEnabled() {
if (document.pictureInPictureEnabled) {

View File

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

View File

@ -838,8 +838,7 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {
if (navDrawerInstance) {
navDrawerInstance.setEdgeSwipeEnabled(true);
}
} else {
if (isDashboardPage) {
} else if (isDashboardPage) {
bodyClassList.remove('libraryDocument');
bodyClassList.add('dashboardDocument');
bodyClassList.remove('hideMainDrawer');
@ -857,7 +856,6 @@ function updateMenuForPageType(isDashboardPage, isLibraryPage) {
}
}
}
}
if (requiresUserRefresh) {
ServerConnections.user(getCurrentApiClient()).then(updateUserInHeader);

View File

@ -54,14 +54,12 @@ export function toCenter(container, elem, horizontal, skipWhenVisible) {
} else {
container.scrollTo(0, pos.center);
}
} else {
if (horizontal) {
} else if (horizontal) {
container.scrollLeft = Math.round(pos.center);
} else {
container.scrollTop = Math.round(pos.center);
}
}
}
export function toStart(container, elem, horizontal, skipWhenVisible) {
const pos = getPosition(container, elem, horizontal);
@ -76,14 +74,12 @@ export function toStart(container, elem, horizontal, skipWhenVisible) {
} else {
container.scrollTo(0, pos.start);
}
} else {
if (horizontal) {
} else if (horizontal) {
container.scrollLeft = Math.round(pos.start);
} else {
container.scrollTop = Math.round(pos.start);
}
}
}
function centerOnFocus(e, scrollSlider, horizontal) {
const focused = focusManager.focusableParent(e.target);