T-013: 'Löschen' für geladene/fehlerhafte Jobs (Verzeichnis+Queue-Eintrag), Worker-Guards gegen Löschung während laufendem Download
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
downloadList,
|
||||
downloadEnqueue,
|
||||
downloadCancel,
|
||||
downloadDelete,
|
||||
onDownloadUpdate,
|
||||
type Book,
|
||||
type DlItem,
|
||||
@ -106,6 +107,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function loeschen(b: Book): Promise<void> {
|
||||
error = ''
|
||||
info = ''
|
||||
try {
|
||||
await downloadDelete(b.asin)
|
||||
const rest = { ...downloads }
|
||||
delete rest[b.asin]
|
||||
downloads = rest
|
||||
const ro = { ...loadedOverride }
|
||||
delete ro[b.asin]
|
||||
loadedOverride = ro
|
||||
} catch (e) {
|
||||
error = String(e)
|
||||
}
|
||||
}
|
||||
|
||||
function hideBrokenCover(e: Event): void {
|
||||
;(e.currentTarget as HTMLElement).style.display = 'none'
|
||||
}
|
||||
@ -323,7 +340,13 @@
|
||||
{#if dlg === 'queued'}<span class="muted small">wartet…</span>{/if}
|
||||
{:else if d && d.status === 'failed'}
|
||||
<button class="ghost" onclick={() => laden(b)}>Nochmal laden</button>
|
||||
<button class="ghost" onclick={() => loeschen(b)}>Löschen</button>
|
||||
<span class="muted small" title={d.msg}>{d.msg.slice(0, 60)}</span>
|
||||
{:else if d && d.status === 'done'}
|
||||
<button class="ghost" onclick={() => loeschen(b)}>Löschen</button>
|
||||
{:else if d && d.status === 'cancelled'}
|
||||
<button class="ghost" onclick={() => laden(b)}>Laden</button>
|
||||
<button class="ghost" onclick={() => loeschen(b)}>Löschen</button>
|
||||
{:else if !isLocal(b)}
|
||||
<button class="primary" onclick={() => laden(b)}>Laden</button>
|
||||
{/if}
|
||||
|
||||
@ -35,5 +35,6 @@ export interface DlItem {
|
||||
export const downloadList = () => invoke<DlItem[]>('download_list')
|
||||
export const downloadEnqueue = (asin: string) => invoke<DlItem>('download_enqueue', { asin })
|
||||
export const downloadCancel = (asin: string) => invoke<DlItem>('download_cancel', { asin })
|
||||
export const downloadDelete = (asin: string) => invoke<void>('download_delete', { asin })
|
||||
export const onDownloadUpdate = (cb: (it: DlItem) => void) =>
|
||||
listen<DlItem>('download-update', (ev) => cb(ev.payload))
|
||||
|
||||
Reference in New Issue
Block a user