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

Merge pull request #3980 from thornbill/fix-sonar-issues

This commit is contained in:
Bill Thornton 2022-10-04 10:17:34 -04:00 committed by GitHub
commit 82f4371f7f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 69 deletions

View file

@ -72,15 +72,11 @@ module.exports = {
'sonarjs/cognitive-complexity': ['warn'], 'sonarjs/cognitive-complexity': ['warn'],
// TODO: Enable the following rules and fix issues // TODO: Enable the following rules and fix issues
'sonarjs/max-switch-cases': ['off'],
'sonarjs/no-duplicate-string': ['off'], 'sonarjs/no-duplicate-string': ['off'],
'sonarjs/no-duplicated-branches': ['off'], 'sonarjs/no-duplicated-branches': ['off'],
'sonarjs/no-gratuitous-expressions': ['off'],
'sonarjs/no-identical-functions': ['off'], 'sonarjs/no-identical-functions': ['off'],
'sonarjs/no-nested-switch': ['off'],
'sonarjs/no-redundant-jump': ['off'], 'sonarjs/no-redundant-jump': ['off'],
'sonarjs/no-small-switch': ['off'], 'sonarjs/no-small-switch': ['off'],
'sonarjs/no-unused-collection': ['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

@ -132,6 +132,7 @@ function saveValues(context, settings, settingsKey) {
seriesStatuses.push(elems[i].getAttribute('data-filter')); seriesStatuses.push(elems[i].getAttribute('data-filter'));
} }
} }
userSettings.setFilter(`${settingsKey}-filter-SeriesStatus`, seriesStatuses.join(','));
// Genres // Genres
const genres = []; const genres = [];

View file

@ -144,10 +144,13 @@ class SubtitleSync {
} }
toggle(action) { toggle(action) {
if (action && !['hide', 'forceToHide'].includes(action)) {
console.warn('SubtitleSync.toggle called with invalid action', action);
return;
}
if (player && playbackManager.supportSubtitleOffset(player)) { if (player && playbackManager.supportSubtitleOffset(player)) {
/* eslint-disable no-fallthrough */ if (!action) {
switch (action) {
case undefined:
// if showing subtitle sync is enabled and if there is an external subtitle stream enabled // if showing subtitle sync is enabled and if there is an external subtitle stream enabled
if (playbackManager.isShowingSubtitleOffsetEnabled(player) && playbackManager.canHandleOffsetOnCurrentSubtitle(player)) { if (playbackManager.isShowingSubtitleOffsetEnabled(player) && playbackManager.canHandleOffsetOnCurrentSubtitle(player)) {
// if no subtitle offset is defined or element has focus (offset being defined) // if no subtitle offset is defined or element has focus (offset being defined)
@ -159,18 +162,14 @@ class SubtitleSync {
} }
// show subtitle sync // show subtitle sync
subtitleSyncContainer.classList.remove('hide'); subtitleSyncContainer.classList.remove('hide');
break; // stop here return;
} // else continue and hide
case 'hide':
// only break if element has focus
if (subtitleSyncTextField.hasFocus) {
break;
} }
case 'forceToHide': } else if (action === 'hide' && subtitleSyncTextField.hasFocus) {
// do not hide if element has focus
return;
}
subtitleSyncContainer.classList.add('hide'); subtitleSyncContainer.classList.add('hide');
break;
}
/* eslint-enable no-fallthrough */
} }
} }
} }

View file

@ -458,7 +458,7 @@ import confirm from '../../components/confirm/confirm';
html += ' / '; html += ' / ';
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) { if (nowPlayingItem.RunTimeTicks) {
html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks); html += datetime.getDisplayRunningTime(nowPlayingItem.RunTimeTicks);
} else { } else {
html += '0:00'; html += '0:00';

View file

@ -1,57 +1,61 @@
const BASE_DEVICE_IMAGE_URL = 'assets/img/devices/';
/* eslint-disable indent */ function getWebDeviceIcon(browser) {
switch (browser) {
export function getDeviceIcon(device) {
const baseUrl = 'assets/img/devices/';
switch (device.AppName || device.Client) {
case 'Samsung Smart TV':
return baseUrl + 'samsung.svg';
case 'Xbox One':
return baseUrl + 'xbox.svg';
case 'Sony PS4':
return baseUrl + 'playstation.svg';
case 'Kodi':
case 'Kodi JellyCon':
return baseUrl + 'kodi.svg';
case 'Jellyfin Android':
case 'AndroidTV':
case 'Android TV':
return baseUrl + 'android.svg';
case 'Jellyfin Mobile (iOS)':
case 'Jellyfin Mobile (iPadOS)':
case 'Jellyfin iOS':
case 'Infuse':
return baseUrl + 'apple.svg';
case 'Jellyfin Web':
switch (device.Name || device.DeviceName) {
case 'Opera': case 'Opera':
case 'Opera TV': case 'Opera TV':
case 'Opera Android': case 'Opera Android':
return baseUrl + 'opera.svg'; return BASE_DEVICE_IMAGE_URL + 'opera.svg';
case 'Chrome': case 'Chrome':
case 'Chrome Android': case 'Chrome Android':
return baseUrl + 'chrome.svg'; return BASE_DEVICE_IMAGE_URL + 'chrome.svg';
case 'Firefox': case 'Firefox':
case 'Firefox Android': case 'Firefox Android':
return baseUrl + 'firefox.svg'; return BASE_DEVICE_IMAGE_URL + 'firefox.svg';
case 'Safari': case 'Safari':
case 'Safari iPad': case 'Safari iPad':
case 'Safari iPhone': case 'Safari iPhone':
return baseUrl + 'safari.svg'; return BASE_DEVICE_IMAGE_URL + 'safari.svg';
case 'Edge Chromium': case 'Edge Chromium':
case 'Edge Chromium Android': case 'Edge Chromium Android':
case 'Edge Chromium iPad': case 'Edge Chromium iPad':
case 'Edge Chromium iPhone': case 'Edge Chromium iPhone':
return baseUrl + 'edgechromium.svg'; return BASE_DEVICE_IMAGE_URL + 'edgechromium.svg';
case 'Edge': case 'Edge':
return baseUrl + 'edge.svg'; return BASE_DEVICE_IMAGE_URL + 'edge.svg';
case 'Internet Explorer': case 'Internet Explorer':
return baseUrl + 'msie.svg'; return BASE_DEVICE_IMAGE_URL + 'msie.svg';
default: default:
return baseUrl + 'html5.svg'; return BASE_DEVICE_IMAGE_URL + 'html5.svg';
} }
}
/* eslint-disable indent */
export function getDeviceIcon(device) {
switch (device.AppName || device.Client) {
case 'Samsung Smart TV':
return BASE_DEVICE_IMAGE_URL + 'samsung.svg';
case 'Xbox One':
return BASE_DEVICE_IMAGE_URL + 'xbox.svg';
case 'Sony PS4':
return BASE_DEVICE_IMAGE_URL + 'playstation.svg';
case 'Kodi':
case 'Kodi JellyCon':
return BASE_DEVICE_IMAGE_URL + 'kodi.svg';
case 'Jellyfin Android':
case 'AndroidTV':
case 'Android TV':
return BASE_DEVICE_IMAGE_URL + 'android.svg';
case 'Jellyfin Mobile (iOS)':
case 'Jellyfin Mobile (iPadOS)':
case 'Jellyfin iOS':
case 'Infuse':
return BASE_DEVICE_IMAGE_URL + 'apple.svg';
case 'Jellyfin Web':
return getWebDeviceIcon(device.Name || device.DeviceName);
default: default:
return baseUrl + 'other.svg'; return BASE_DEVICE_IMAGE_URL + 'other.svg';
} }
} }

View file

@ -123,16 +123,11 @@ function processGeneralCommand(cmd, apiClient) {
displayMessage(cmd); displayMessage(cmd);
break; break;
case 'ToggleOsd': case 'ToggleOsd':
// todo
break;
case 'ToggleContextMenu': case 'ToggleContextMenu':
// todo
break;
case 'SendKey': case 'SendKey':
// todo // todo
break; break;
case 'SendString': case 'SendString':
// todo
focusManager.sendText(cmd.Arguments.String); focusManager.sendText(cmd.Arguments.String);
break; break;
default: default: