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

Fix sonar critical issue with switch fallthrough

This commit is contained in:
Bill Thornton 2022-10-02 04:13:39 -04:00
parent ccdbf0bfc3
commit dfca85dea4

View file

@ -144,33 +144,32 @@ 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) { // if showing subtitle sync is enabled and if there is an external subtitle stream enabled
case undefined: if (playbackManager.isShowingSubtitleOffsetEnabled(player) && playbackManager.canHandleOffsetOnCurrentSubtitle(player)) {
// if showing subtitle sync is enabled and if there is an external subtitle stream enabled // if no subtitle offset is defined or element has focus (offset being defined)
if (playbackManager.isShowingSubtitleOffsetEnabled(player) && playbackManager.canHandleOffsetOnCurrentSubtitle(player)) { if (!(playbackManager.getPlayerSubtitleOffset(player) || subtitleSyncTextField.hasFocus)) {
// if no subtitle offset is defined or element has focus (offset being defined) // set default offset to '0' = 50%
if (!(playbackManager.getPlayerSubtitleOffset(player) || subtitleSyncTextField.hasFocus)) { subtitleSyncSlider.value = '50';
// set default offset to '0' = 50% subtitleSyncTextField.textContent = '0s';
subtitleSyncSlider.value = '50'; playbackManager.setSubtitleOffset(0, player);
subtitleSyncTextField.textContent = '0s';
playbackManager.setSubtitleOffset(0, player);
}
// show subtitle sync
subtitleSyncContainer.classList.remove('hide');
break; // stop here
} // else continue and hide
case 'hide':
// only break if element has focus
if (subtitleSyncTextField.hasFocus) {
break;
} }
case 'forceToHide': // show subtitle sync
subtitleSyncContainer.classList.add('hide'); subtitleSyncContainer.classList.remove('hide');
break; return;
}
} else if (action === 'hide' && subtitleSyncTextField.hasFocus) {
// do not hide if element has focus
return;
} }
/* eslint-enable no-fallthrough */
subtitleSyncContainer.classList.add('hide');
} }
} }
} }