1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix sonarjs no-small-switch

This commit is contained in:
Bill Thornton 2022-10-08 03:18:30 -04:00
parent 762573bef8
commit 76ed503c81
8 changed files with 29 additions and 46 deletions

View file

@ -77,7 +77,6 @@ module.exports = {
// TODO: Enable the following rules and fix issues // TODO: Enable the following rules and fix issues
'sonarjs/no-duplicate-string': ['off'], 'sonarjs/no-duplicate-string': ['off'],
'sonarjs/no-redundant-jump': ['off'], 'sonarjs/no-redundant-jump': ['off'],
'sonarjs/no-small-switch': ['off'],
'sonarjs/prefer-object-literal': ['off'], 'sonarjs/prefer-object-literal': ['off'],
'sonarjs/prefer-single-boolean-return': ['off'] 'sonarjs/prefer-single-boolean-return': ['off']
}, },

View file

@ -273,28 +273,23 @@ import { Events } from 'jellyfin-apiclient';
hls.on(Hls.Events.ERROR, function (event, data) { hls.on(Hls.Events.ERROR, function (event, data) {
console.error('HLS Error: Type: ' + data.type + ' Details: ' + (data.details || '') + ' Fatal: ' + (data.fatal || false)); console.error('HLS Error: Type: ' + data.type + ' Details: ' + (data.details || '') + ' Fatal: ' + (data.fatal || false));
switch (data.type) { // try to recover network error
case Hls.ErrorTypes.NETWORK_ERROR: if (data.type === Hls.ErrorTypes.NETWORK_ERROR
// try to recover network error && data.response?.code && data.response.code >= 400
if (data.response && data.response.code && data.response.code >= 400) { ) {
console.debug('hls.js response error code: ' + data.response.code); console.debug('hls.js response error code: ' + data.response.code);
// Trigger failure differently depending on whether this is prior to start of playback, or after // Trigger failure differently depending on whether this is prior to start of playback, or after
hls.destroy(); hls.destroy();
if (reject) { if (reject) {
reject('servererror'); reject('servererror');
reject = null; reject = null;
} else { } else {
onErrorInternal(instance, 'servererror'); onErrorInternal(instance, 'servererror');
} }
return; return;
}
break;
default:
break;
} }
if (data.fatal) { if (data.fatal) {

View file

@ -334,12 +334,8 @@ function showDownloadOptions(button, context, subtitleId) {
positionTo: button positionTo: button
}).then(function (id) { }).then(function (id) {
switch (id) { if (id === 'download') {
case 'download': downloadRemoteSubtitles(context, subtitleId);
downloadRemoteSubtitles(context, subtitleId);
break;
default:
break;
} }
}); });
}); });

View file

@ -66,11 +66,9 @@ function renderRecordingFolders(context, promise) {
function onMoreClick() { function onMoreClick() {
const type = this.getAttribute('data-type'); const type = this.getAttribute('data-type');
const serverId = ApiClient.serverId();
switch (type) { if (type === 'latest') {
case 'latest': Dashboard.navigate('list.html?type=Recordings&serverId=' + ApiClient.serverId());
Dashboard.navigate('list.html?type=Recordings&serverId=' + serverId);
} }
} }

View file

@ -374,10 +374,9 @@ import Dashboard from '../../utils/dashboard';
} }
function onInputCommand(e) { function onInputCommand(e) {
switch (e.detail.command) { if (e.detail.command === 'search') {
case 'search': e.preventDefault();
e.preventDefault(); Dashboard.navigate('search.html?collectionType=movies&parentId=' + params.topParentId);
Dashboard.navigate('search.html?collectionType=movies&parentId=' + params.topParentId);
} }
} }

View file

@ -348,10 +348,9 @@ import Dashboard from '../../utils/dashboard';
} }
function onInputCommand(e) { function onInputCommand(e) {
switch (e.detail.command) { if (e.detail.command === 'search') {
case 'search': e.preventDefault();
e.preventDefault(); Dashboard.navigate('search.html?collectionType=music&parentId=' + params.topParentId);
Dashboard.navigate('search.html?collectionType=music&parentId=' + params.topParentId);
} }
} }

View file

@ -333,10 +333,9 @@ import autoFocuser from '../../components/autoFocuser';
} }
function onInputCommand(e) { function onInputCommand(e) {
switch (e.detail.command) { if (e.detail.command === 'search') {
case 'search': e.preventDefault();
e.preventDefault(); Dashboard.navigate('search.html?collectionType=tv&parentId=' + params.topParentId);
Dashboard.navigate('search.html?collectionType=tv&parentId=' + params.topParentId);
} }
} }

View file

@ -172,10 +172,8 @@ export class ComicsPlayer {
onWindowKeyUp(e) { onWindowKeyUp(e) {
const key = keyboardnavigation.getKeyName(e); const key = keyboardnavigation.getKeyName(e);
switch (key) { if (key === 'Escape') {
case 'Escape': this.stop();
this.stop();
break;
} }
} }