fix: remove noop arrow functions in player
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { state } from '../state';
|
||||
import { SkipSegment } from '../types';
|
||||
import type { SkipSegment } from '../types';
|
||||
import { resolveActiveSegments, renderSegments } from '../skip/segments';
|
||||
import { updateSubtitleOptions } from '../subtitles';
|
||||
import { updateQualityOptions } from '../quality';
|
||||
@@ -74,7 +74,9 @@ export const goToNextEpisode = async (): Promise<void> => {
|
||||
const preferredQuality = localStorage.getItem('mal:preferred-quality') || 'best';
|
||||
state.video.src = `${state.streamURL}?mode=${encodeURIComponent(fallback)}&token=${encodeURIComponent(state.modeSources[fallback].token)}${preferredQuality !== 'best' ? `&quality=${encodeURIComponent(preferredQuality)}` : ''}`;
|
||||
state.video.load();
|
||||
if (!state.video.paused) state.video.play().catch(() => {});
|
||||
if (!state.video.paused) {
|
||||
state.video.play().catch(() => undefined);
|
||||
}
|
||||
|
||||
state.pendingSeekTime = null;
|
||||
state.completionSent = false;
|
||||
|
||||
@@ -116,7 +116,9 @@ const initPlayer = (): void => {
|
||||
}
|
||||
|
||||
const onLoadedMetadata = (): void => {
|
||||
loading && (loading.style.display = 'none');
|
||||
if (loading) {
|
||||
loading.style.display = 'none';
|
||||
}
|
||||
invalidateBounds();
|
||||
|
||||
resolveActiveSegments();
|
||||
@@ -136,7 +138,9 @@ const initPlayer = (): void => {
|
||||
state.transitionEpisode = null;
|
||||
}
|
||||
// autoplay if not already playing (inline script may have already called play())
|
||||
if (state.shouldAutoPlay || state.video.paused) state.video.play().catch(() => {});
|
||||
if (state.shouldAutoPlay || state.video.paused) {
|
||||
state.video.play().catch(() => undefined);
|
||||
}
|
||||
|
||||
updateTimeline(state.video.currentTime);
|
||||
updateSkipButton(state.video.currentTime);
|
||||
@@ -150,10 +154,14 @@ const initPlayer = (): void => {
|
||||
}
|
||||
|
||||
state.video.addEventListener('waiting', () => {
|
||||
loading && (loading.style.display = 'flex');
|
||||
if (loading) {
|
||||
loading.style.display = 'flex';
|
||||
}
|
||||
});
|
||||
state.video.addEventListener('playing', () => {
|
||||
loading && (loading.style.display = 'none');
|
||||
if (loading) {
|
||||
loading.style.display = 'none';
|
||||
}
|
||||
});
|
||||
// update progress bar during buffering
|
||||
state.video.addEventListener('progress', () => {
|
||||
|
||||
@@ -21,7 +21,9 @@ const loadVideo = (url: string): void => {
|
||||
state.video.src = url;
|
||||
state.video.load();
|
||||
state.pendingSeekTime = prevTime; // restored in loadedmetadata handler
|
||||
if (wasPlaying) state.video.play().catch(() => {});
|
||||
if (wasPlaying) {
|
||||
state.video.play().catch(() => undefined);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -51,13 +53,17 @@ export const updateModeButtons = (): void => {
|
||||
dub?.classList.toggle('text-foreground', m !== 'dub');
|
||||
dub?.classList.toggle('opacity-50', !state.availableModes.includes('dub'));
|
||||
dub?.classList.toggle('cursor-not-allowed', !state.availableModes.includes('dub'));
|
||||
dub && (dub.disabled = !state.availableModes.includes('dub'));
|
||||
if (dub) {
|
||||
dub.disabled = !state.availableModes.includes('dub');
|
||||
}
|
||||
|
||||
sub?.classList.toggle('text-accent', m === 'sub');
|
||||
sub?.classList.toggle('text-foreground', m !== 'sub');
|
||||
sub?.classList.toggle('opacity-50', !state.availableModes.includes('sub'));
|
||||
sub?.classList.toggle('cursor-not-allowed', !state.availableModes.includes('sub'));
|
||||
sub && (sub.disabled = !state.availableModes.includes('sub'));
|
||||
if (sub) {
|
||||
sub.disabled = !state.availableModes.includes('sub');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -89,7 +89,7 @@ export const markEpisodeTransition = (episodeNumber: number): void => {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
keepalive: true,
|
||||
body: payload,
|
||||
}).catch(() => {});
|
||||
}).catch(() => undefined);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ const loadVideo = (url: string): void => {
|
||||
state.video.src = url;
|
||||
state.video.load();
|
||||
state.pendingSeekTime = prevTime;
|
||||
if (wasPlaying) state.video.play().catch(() => {});
|
||||
if (wasPlaying) {
|
||||
state.video.play().catch(() => undefined);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,7 +48,8 @@ export const updateSkipButton = (currentTime: number): void => {
|
||||
*/
|
||||
export const updateAutoSkipButton = (): void => {
|
||||
const btn = document.querySelector('[data-autoskip]') as HTMLInputElement | null;
|
||||
btn && (btn.checked = localStorage.getItem('mal:autoskip-enabled') === 'true');
|
||||
if (!btn) return;
|
||||
btn.checked = localStorage.getItem('mal:autoskip-enabled') === 'true';
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user