fix: mpv loadfile index arg, cache polling, and sidebar CSS

- Pass integer index (-1) to mpv loadfile command for newer mpv versions
- Poll /api/cache/status instead of streaming endpoints to avoid
  downloading video bodies during readiness checks
- Cancel previous polling when selecting a new file
- Fix sidebar flex-shrink and file name text overflow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-17 08:17:23 +02:00
parent 2b6c56cd15
commit a67e189aa0
4 changed files with 43 additions and 7 deletions
+19
View File
@@ -63,6 +63,25 @@ export function audioUrl(path: string, root: string): string {
return `${serverUrl}/api/audio/${encodePath(path)}?root=${encodeURIComponent(root)}`;
}
/** Poll cache status until both video and audio are ready. */
export async function waitForCache(
path: string, root: string, quality: string,
signal: AbortSignal, interval = 2000
): Promise<void> {
const url = `${serverUrl}/api/cache/status/${encodePath(path)}?root=${encodeURIComponent(root)}`;
// Trigger transcode/audio extraction by hitting stream+audio once
await fetch(streamUrl(path, root, quality), { signal }).catch(() => {});
await fetch(audioUrl(path, root), { signal }).catch(() => {});
while (!signal.aborted) {
const res = await fetch(url, { signal });
const status = await res.json();
if (status[quality] === "ready" && status.audio === "ready") return;
await new Promise(r => setTimeout(r, interval));
}
throw new Error("Aborted");
}
export function cacheStatus(path: string, root: string): Promise<Record<string, string>> {
return get(`/api/cache/status/${encodePath(path)}?root=${encodeURIComponent(root)}`);
}