diff --git a/backend/record.go b/backend/record.go index 894f516..7ae660c 100644 --- a/backend/record.go +++ b/backend/record.go @@ -1466,6 +1466,8 @@ func recordRemoveQueuedPostwork(w http.ResponseWriter, r *http.Request) { respondJSON(w, map[string]any{ "ok": true, "id": id, + "file": filepath.Base(out), + "output": out, "removedAudioSidecars": len(removedAudioSidecars), }) } diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 93b533f..1fb7bb5 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -3124,12 +3124,76 @@ export default function App() { } async function removeQueuedPostworkJob(id: string) { + const cleanId = String(id || '').trim() + if (!cleanId) return + + const beforeJob = + jobsRef.current.find((j) => String((j as any)?.id ?? '').trim() === cleanId) ?? + jobs.find((j) => String((j as any)?.id ?? '').trim() === cleanId) ?? + null + + const beforeFile = baseName(beforeJob?.output || '') + try { - await apiJSON(`/api/record/postwork/remove?id=${encodeURIComponent(id)}`, { + const data = await apiJSON<{ + ok?: boolean + id?: string + file?: string + output?: string + }>(`/api/record/postwork/remove?id=${encodeURIComponent(cleanId)}`, { method: 'POST', }) + + if (data?.ok !== true) { + return + } + + const removedId = String(data.id || cleanId).trim() + const removedFile = + baseName(String(data.file || data.output || beforeFile || '')) + + delete lastSeenAtByJobIdRef.current[removedId] + + setJobs((prev) => { + const next = prev.filter((j) => { + const jid = String((j as any)?.id ?? '').trim() + return jid !== removedId + }) + + jobsRef.current = next + return next + }) + + setPlayerJob((prev) => { + if (!prev) return prev + + const sameId = String((prev as any)?.id ?? '').trim() === removedId + const sameFile = + removedFile && + baseName(prev.output || '') === removedFile + + return sameId || sameFile ? null : prev + }) + + setDoneJobs((prev) => + prev.filter((j) => { + const jid = String((j as any)?.id ?? '').trim() + const file = baseName(j.output || '') + + if (jid && jid === removedId) return false + if (removedFile && file === removedFile) return false + + return true + }) + ) + + donePrefetchRef.current = null + + void loadDonePageRef.current(donePageRef.current, doneSortRef.current) + void loadDoneCount() } catch (e: any) { notify.error('Entfernen fehlgeschlagen', e?.message ?? String(e)) + throw e } }