add eslint no-nested-ternary rule and fix violations
This commit is contained in:
parent
ab5fad6d5b
commit
d895a4fc6a
15 changed files with 89 additions and 30 deletions
|
@ -52,9 +52,10 @@ module.exports = {
|
|||
'no-trailing-spaces': ['error'],
|
||||
'@babel/no-unused-expressions': ['error', { 'allowShortCircuit': true, 'allowTernary': true, 'allowTaggedTemplates': true }],
|
||||
'no-void': ['error', { 'allowAsStatement': true }],
|
||||
'no-nested-ternary': ['error'],
|
||||
'one-var': ['error', 'never'],
|
||||
'padded-blocks': ['error', 'never'],
|
||||
'prefer-const': ['error', {'destructuring': 'all'}],
|
||||
'prefer-const': ['error', { 'destructuring': 'all' }],
|
||||
'quotes': ['error', 'single', { 'avoidEscape': true, 'allowTemplateLiterals': false }],
|
||||
'@babel/semi': ['error'],
|
||||
'no-var': ['error'],
|
||||
|
|
|
@ -121,10 +121,14 @@ import '../elements/emby-itemscontainer/emby-itemscontainer';
|
|||
}
|
||||
|
||||
if (!isSingleSection) {
|
||||
options.Limit = screenWidth >= 1920 ? 10 : screenWidth >= 1440 ? 8 : 6;
|
||||
options.Limit = 6;
|
||||
|
||||
if (enableScrollX()) {
|
||||
options.Limit = 20;
|
||||
} else if (screenWidth >= 1920) {
|
||||
options.Limit = 10;
|
||||
} else if (screenWidth >= 1440) {
|
||||
options.Limit = 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import escapeHtml from 'escape-html';
|
||||
import cardBuilder from '../cardbuilder/cardBuilder';
|
||||
import dom from '../../scripts/dom';
|
||||
import layoutManager from '../layoutManager';
|
||||
import imageLoader from '../images/imageLoader';
|
||||
import globalize from '../../scripts/globalize';
|
||||
|
@ -401,15 +400,8 @@ import ServerConnections from '../ServerConnections';
|
|||
function getItemsToResumeFn(mediaType, serverId) {
|
||||
return function () {
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
const screenWidth = dom.getWindowSize().innerWidth;
|
||||
|
||||
let limit;
|
||||
if (enableScrollX()) {
|
||||
limit = 12;
|
||||
} else {
|
||||
limit = screenWidth >= 1920 ? 8 : (screenWidth >= 1600 ? 8 : (screenWidth >= 1200 ? 9 : 6));
|
||||
limit = Math.min(limit, 5);
|
||||
}
|
||||
const limit = enableScrollX() ? 12 : 5;
|
||||
|
||||
const options = {
|
||||
Limit: limit,
|
||||
|
|
|
@ -520,7 +520,14 @@ import toast from './toast/toast';
|
|||
}
|
||||
|
||||
function play(item, resume, queue, queueNext) {
|
||||
const method = queue ? (queueNext ? 'queueNext' : 'queue') : 'play';
|
||||
let method = 'play';
|
||||
if (queue) {
|
||||
if (queueNext) {
|
||||
method = 'queueNext';
|
||||
} else {
|
||||
method = 'queue';
|
||||
}
|
||||
}
|
||||
|
||||
let startPosition = 0;
|
||||
if (resume && item.UserData && item.UserData.PlaybackPositionTicks) {
|
||||
|
|
|
@ -550,7 +550,13 @@ import template from './libraryoptionseditor.template.html';
|
|||
function getOrderedPlugins(plugins, configuredOrder) {
|
||||
plugins = plugins.slice(0);
|
||||
plugins.sort((a, b) => {
|
||||
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), a < b ? -1 : a > b ? 1 : 0;
|
||||
let order = 0;
|
||||
if (a < b) {
|
||||
order = -1;
|
||||
} else if (a > b) {
|
||||
order = 1;
|
||||
}
|
||||
return a = configuredOrder.indexOf(a.Name), b = configuredOrder.indexOf(b.Name), order;
|
||||
});
|
||||
return plugins;
|
||||
}
|
||||
|
|
|
@ -1827,12 +1827,18 @@ class PlaybackManager {
|
|||
Limit: UNLIMITED_ITEMS
|
||||
}, queryOptions));
|
||||
} else if (firstItem.IsFolder) {
|
||||
let sortBy = null;
|
||||
if (options.shuffle) {
|
||||
sortBy = 'Random';
|
||||
} else if (firstItem.Type !== 'BoxSet') {
|
||||
sortBy = 'SortName';
|
||||
}
|
||||
promise = getItemsForPlayback(serverId, mergePlaybackQueries({
|
||||
ParentId: firstItem.Id,
|
||||
Filters: 'IsNotFolder',
|
||||
Recursive: true,
|
||||
// These are pre-sorted
|
||||
SortBy: options.shuffle ? 'Random' : (['BoxSet'].indexOf(firstItem.Type) === -1 ? 'SortName' : null),
|
||||
SortBy: sortBy,
|
||||
MediaTypes: 'Audio,Video'
|
||||
}, queryOptions));
|
||||
} else if (firstItem.Type === 'Episode' && items.length === 1 && getPlayer(firstItem, options).supportsProgress !== false) {
|
||||
|
|
|
@ -61,7 +61,12 @@ import layoutManager from './layoutManager';
|
|||
* @return {number} Clamped value.
|
||||
*/
|
||||
function clamp(value, min, max) {
|
||||
return value <= min ? min : value >= max ? max : value;
|
||||
if (value <= min) {
|
||||
return min;
|
||||
} else if (value >= max) {
|
||||
return max;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -173,12 +173,18 @@ export function translateItemsForPlayback(apiClient, items, options) {
|
|||
MediaTypes: 'Audio'
|
||||
});
|
||||
} else if (firstItem.IsFolder) {
|
||||
let sortBy = null;
|
||||
if (options.shuffle) {
|
||||
sortBy = 'Random';
|
||||
} else if (firstItem.Type === 'BoxSet') {
|
||||
sortBy = 'SortName';
|
||||
}
|
||||
promise = getItemsForPlayback(apiClient, mergePlaybackQueries({
|
||||
ParentId: firstItem.Id,
|
||||
Filters: 'IsNotFolder',
|
||||
Recursive: true,
|
||||
// These are pre-sorted.
|
||||
SortBy: options.shuffle ? 'Random' : (['BoxSet'].indexOf(firstItem.Type) === -1 ? 'SortName' : null),
|
||||
SortBy: sortBy,
|
||||
MediaTypes: 'Audio,Video'
|
||||
}, queryOptions));
|
||||
} else if (firstItem.Type === 'Episode' && items.length === 1) {
|
||||
|
|
|
@ -23,7 +23,13 @@ import '../../../elements/emby-button/emby-button';
|
|||
tasks = tasks.sort(function(a, b) {
|
||||
a = a.Category + ' ' + a.Name;
|
||||
b = b.Category + ' ' + b.Name;
|
||||
return a == b ? 0 : a < b ? -1 : 1;
|
||||
if (a > b) {
|
||||
return 1;
|
||||
} else if (a < b) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
let currentCategory;
|
||||
|
|
|
@ -66,7 +66,7 @@ import Dashboard from '../../utils/dashboard';
|
|||
SortOrder: 'Descending',
|
||||
IncludeItemTypes: 'Movie',
|
||||
Filters: 'IsResumable',
|
||||
Limit: screenWidth >= 1920 ? 5 : screenWidth >= 1600 ? 5 : 3,
|
||||
Limit: screenWidth >= 1600 ? 5 : 3,
|
||||
Recursive: true,
|
||||
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
||||
CollapseBoxSetItems: false,
|
||||
|
@ -157,10 +157,17 @@ import Dashboard from '../../utils/dashboard';
|
|||
|
||||
function loadSuggestions(page, userId) {
|
||||
const screenWidth = dom.getWindowSize().innerWidth;
|
||||
let itemLimit = 5;
|
||||
if (screenWidth >= 1600) {
|
||||
itemLimit = 8;
|
||||
} else if (screenWidth >= 1200) {
|
||||
itemLimit = 6;
|
||||
}
|
||||
|
||||
const url = ApiClient.getUrl('Movies/Recommendations', {
|
||||
userId: userId,
|
||||
categoryLimit: 6,
|
||||
ItemLimit: screenWidth >= 1920 ? 8 : screenWidth >= 1600 ? 8 : screenWidth >= 1200 ? 6 : 5,
|
||||
ItemLimit: itemLimit,
|
||||
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
||||
ImageTypeLimit: 1,
|
||||
EnableImageTypes: 'Primary,Backdrop,Banner,Thumb'
|
||||
|
|
|
@ -587,7 +587,12 @@ import { setBackdropTransparency, TRANSPARENCY_LEVEL } from '../../../components
|
|||
|
||||
function showComingUpNextIfNeeded(player, currentItem, currentTimeTicks, runtimeTicks) {
|
||||
if (runtimeTicks && currentTimeTicks && !comingUpNextDisplayed && !currentVisibleMenu && currentItem.Type === 'Episode' && userSettings.enableNextVideoInfoOverlay()) {
|
||||
const showAtSecondsLeft = runtimeTicks >= 3e10 ? 40 : runtimeTicks >= 24e9 ? 35 : 30;
|
||||
let showAtSecondsLeft = 30;
|
||||
if (runtimeTicks >= 3e10) {
|
||||
showAtSecondsLeft = 40;
|
||||
} else if (runtimeTicks >= 2.4e10) {
|
||||
showAtSecondsLeft = 35;
|
||||
}
|
||||
const showAtTicks = runtimeTicks - 1e3 * showAtSecondsLeft * 1e4;
|
||||
const timeRemainingTicks = runtimeTicks - currentTimeTicks;
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ import autoFocuser from '../../components/autoFocuser';
|
|||
SortOrder: 'Descending',
|
||||
IncludeItemTypes: 'Episode',
|
||||
Filters: 'IsResumable',
|
||||
Limit: screenWidth >= 1920 ? 5 : screenWidth >= 1600 ? 5 : 3,
|
||||
Limit: screenWidth >= 1600 ? 5 : 3,
|
||||
Recursive: true,
|
||||
Fields: 'PrimaryImageAspectRatio,MediaSourceCount,BasicSyncInfo',
|
||||
CollapseBoxSetItems: false,
|
||||
|
|
|
@ -53,7 +53,12 @@ function disableOneEvent(event) {
|
|||
* @return {Number}
|
||||
*/
|
||||
function within(number, min, max) {
|
||||
return number < min ? min : number > max ? max : number;
|
||||
if (number < min) {
|
||||
return min;
|
||||
} else if (number > max) {
|
||||
return max;
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
// Other global values
|
||||
|
|
|
@ -288,10 +288,16 @@ import browser from './browser';
|
|||
}
|
||||
}
|
||||
|
||||
return browser.ps4 ? 8000000 :
|
||||
(browser.xboxOne ? 12000000 :
|
||||
(browser.edgeUwp ? null :
|
||||
(browser.tizen && isTizenFhd ? 20000000 : null)));
|
||||
let bitrate = null;
|
||||
if (browser.ps4) {
|
||||
bitrate = 8000000;
|
||||
} else if (browser.xboxOne) {
|
||||
bitrate = 12000000;
|
||||
} else if (browser.tizen && isTizenFhd) {
|
||||
bitrate = 20000000;
|
||||
}
|
||||
|
||||
return bitrate;
|
||||
}
|
||||
|
||||
function getSpeakerCount() {
|
||||
|
@ -381,9 +387,7 @@ import browser from './browser';
|
|||
}
|
||||
|
||||
/* eslint-disable compat/compat */
|
||||
let maxVideoWidth = browser.xboxOne ?
|
||||
(window.screen ? window.screen.width : null) :
|
||||
null;
|
||||
let maxVideoWidth = (browser.xboxOne && window.screen) ? window.screen.width : null;
|
||||
|
||||
/* eslint-enable compat/compat */
|
||||
if (options.maxVideoWidth) {
|
||||
|
|
|
@ -793,7 +793,12 @@ import { getParameterByName } from '../utils/url.ts';
|
|||
}
|
||||
|
||||
function updateMenuForPageType(isDashboardPage, isLibraryPage) {
|
||||
const newPageType = isDashboardPage ? 2 : isLibraryPage ? 1 : 3;
|
||||
let newPageType = 3;
|
||||
if (isDashboardPage) {
|
||||
newPageType = 2;
|
||||
} else if (isLibraryPage) {
|
||||
newPageType = 1;
|
||||
}
|
||||
|
||||
if (currentPageType !== newPageType) {
|
||||
currentPageType = newPageType;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue