This commit is contained in:
Linrador 2026-02-12 19:48:09 +01:00
parent 97eafb10e7
commit 6cd9dcd41e
7 changed files with 39 additions and 102 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>App</title>
<script type="module" crossorigin src="/assets/index-DlgYo3oN.js"></script>
<script type="module" crossorigin src="/assets/index-JupgTTdL.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-SqYhLYXQ.css">
</head>
<body>

View File

@ -1613,10 +1613,6 @@ export default function App() {
setPlayerJob((prev) => (prev && baseName(prev.output || '') === file ? null : prev))
}, 320)
window.setTimeout(() => {
void refreshDoneNow()
}, 350)
const undoToken = typeof data?.undoToken === 'string' ? data.undoToken : ''
return undoToken ? { undoToken } : {} // ✅ kein null mehr
} catch (e: any) {
@ -1653,8 +1649,7 @@ export default function App() {
setJobs((prev) => prev.filter((j) => baseName(j.output || '') !== file))
setPlayerJob((prev) => (prev && baseName(prev.output || '') === file ? null : prev))
}, 320)
void refreshDoneNow()
} catch (e: any) {
window.dispatchEvent(new CustomEvent('finished-downloads:delete', { detail: { file, phase: 'error' as const } }))
notify.error('Keep fehlgeschlagen', e?.message ?? String(e))

View File

@ -1595,64 +1595,6 @@ export default function FinishedDownloads({
}
}, [isSmall])
useEffect(() => {
let es: EventSource | null = null
let closed = false
let reconnectTimer: number | null = null
let refillDebounce: number | null = null
const scheduleRefill = () => {
if (refillDebounce != null) return
refillDebounce = window.setTimeout(() => {
refillDebounce = null
// optional: wenn du gerade "leer" bist, auf Seite 1 springen
// (sonst könntest du auf Seite >1 hängen, während wieder Inhalte kommen)
if (emptyFolder && page !== 1) onPageChange(1)
queueRefill()
}, 80)
}
const connect = () => {
if (closed) return
try {
// ✅ NEU: Done-Change Stream (nicht Job-Snapshot Stream)
es = new EventSource('/api/record/done/stream')
es.onmessage = () => {
// Payload ist egal jede Message heißt: done-Liste hat sich geändert
scheduleRefill()
}
// optional: wenn du serverseitig "event: doneChanged" sendest:
// es.addEventListener('doneChanged', scheduleRefill as any)
es.onerror = () => {
try { es?.close() } catch {}
es = null
if (closed) return
// simple reconnect (du kannst hier auch exponentiell machen)
if (reconnectTimer != null) window.clearTimeout(reconnectTimer)
reconnectTimer = window.setTimeout(connect, 1000)
}
} catch {
if (reconnectTimer != null) window.clearTimeout(reconnectTimer)
reconnectTimer = window.setTimeout(connect, 1000)
}
}
connect()
return () => {
closed = true
if (reconnectTimer != null) window.clearTimeout(reconnectTimer)
if (refillDebounce != null) window.clearTimeout(refillDebounce)
try { es?.close() } catch {}
}
}, [queueRefill, emptyFolder, page, onPageChange])
useEffect(() => {
if (emptyFolder && page !== 1) onPageChange(1)
}, [emptyFolder, page, onPageChange])