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

Use modern syntax & slight perf improvement

This commit is contained in:
gnattu 2024-05-21 17:55:11 +08:00
parent 68bac17a46
commit 0271ae42c0

View file

@ -101,7 +101,7 @@ export function isNavigationKey(key) {
* @return {boolean} _true_ if key is used for media playback control. * @return {boolean} _true_ if key is used for media playback control.
*/ */
export function isMediaKey(key) { export function isMediaKey(key) {
return MediaKeys.indexOf(key) != -1; return MediaKeys.includes(key);
} }
/** /**
@ -123,6 +123,7 @@ export function isInteractiveElement(element) {
} }
export function enable() { export function enable() {
const hasMediaSession = 'mediaSession' in navigator;
window.addEventListener('keydown', function (e) { window.addEventListener('keydown', function (e) {
const key = getKeyName(e); const key = getKeyName(e);
@ -132,7 +133,7 @@ export function enable() {
} }
// Ignore Media Keys for non-TV platform having MediaSession API // Ignore Media Keys for non-TV platform having MediaSession API
if (!layoutManager.tv && isMediaKey(key) && 'mediaSession' in navigator) { if (!layoutManager.tv && isMediaKey(key) && hasMediaSession) {
return; return;
} }