fix: satisfy typecheck in player

This commit is contained in:
2026-05-24 22:47:44 +02:00
parent e87b79bbe1
commit 233beb609c
3 changed files with 16 additions and 20 deletions

View File

@@ -5,12 +5,14 @@ import { state } from '../state';
* Injects images into episode cards, replaces placeholder.
*/
export const setupThumbnails = (): void => {
const episodeList = state.episodeList;
if (!episodeList) return;
fetch(`/api/watch/thumbnails/${state.malID}`)
.then(res => res.json())
.then((data: { mal_id: number; url: string; title?: string }[]) => {
if (!state.episodeList) return;
data.forEach(item => {
const card = state.episodeList.querySelector(`[data-episode-id="${item.mal_id}"]`);
const card = episodeList.querySelector(`[data-episode-id="${item.mal_id}"]`);
if (!card) return;
// inject thumbnail image

View File

@@ -34,7 +34,10 @@ export const switchMode = (mode: string): void => {
if (!state.availableModes.includes(mode) || mode === state.currentMode) return;
state.currentMode = mode;
localStorage.setItem('player-audio-mode', mode);
loadVideo(streamUrlForMode(mode, state.container.querySelector('[data-quality-select]')?.value));
const qualitySelect = state.container.querySelector(
'[data-quality-select]'
) as HTMLSelectElement | null;
loadVideo(streamUrlForMode(mode, qualitySelect?.value));
updateSubtitleOptions();
updateQualityOptions();
updateModeButtons();

View File

@@ -105,27 +105,18 @@ const findElement = <T extends Element>(
};
const requiredPlayerElements = (container: HTMLElement): RequiredPlayerElements | null => {
const elements = {
video: findElement(container, 'video', HTMLVideoElement),
progress: findElement(container, '[data-progress]', HTMLElement),
scrubber: findElement(container, '[data-scrubber]', HTMLElement),
buffered: findElement(container, '[data-buffered]', HTMLElement),
timeDisplay: findElement(container, '[data-time]', HTMLElement),
durationDisplay: findElement(container, '[data-duration]', HTMLElement),
};
const video = findElement(container, 'video', HTMLVideoElement);
const progress = findElement(container, '[data-progress]', HTMLElement);
const scrubber = findElement(container, '[data-scrubber]', HTMLElement);
const buffered = findElement(container, '[data-buffered]', HTMLElement);
const timeDisplay = findElement(container, '[data-time]', HTMLElement);
const durationDisplay = findElement(container, '[data-duration]', HTMLElement);
if (
!elements.video ||
!elements.progress ||
!elements.scrubber ||
!elements.buffered ||
!elements.timeDisplay ||
!elements.durationDisplay
) {
if (!video || !progress || !scrubber || !buffered || !timeDisplay || !durationDisplay) {
return null;
}
return elements;
return { video, progress, scrubber, buffered, timeDisplay, durationDisplay };
};
/**