M1-Politur nach Feedback: lokal statt fertig-Chip + Löschen für lokale Bücher, 'Nur lokale'-Filter, Offline-Scan über ffprobe (lokale Titel auch ohne Netz), Klartext-Fehler ('nicht als Datei', Timeout)

This commit is contained in:
2026-11-06 20:09:07 +01:00
parent 560361004a
commit 5b1749ec78
6 changed files with 196 additions and 31 deletions

View File

@ -4,6 +4,7 @@
startLogin,
startDecrypt,
getLibrary,
getLocalBooks,
downloadList,
downloadEnqueue,
downloadCancel,
@ -27,8 +28,10 @@
let query = $state('')
let sortBy = $state<SortKey>('added')
let onlyLocal = $state(false)
let downloads = $state<Record<string, DlItem>>({})
let loadedOverride = $state<Record<string, boolean>>({})
let removedLocals = $state<Record<string, boolean>>({})
const actives = $derived.by(() => {
let n = 0
@ -45,6 +48,7 @@
const filtered = $derived.by(() => {
const q = query.trim().toLowerCase()
const hits = books.filter((b) => {
if (onlyLocal && !isLocal(b)) return false
if (!q) return true
return (
b.title.toLowerCase().includes(q) ||
@ -74,6 +78,7 @@
}
function isLocal(b: Book): boolean {
if (removedLocals[b.asin]) return false
return Boolean(b.local || loadedOverride[b.asin])
}
@ -140,17 +145,32 @@
error = ''
try {
books = await getLibrary()
// Lokale Titel einpflügen, die (noch) nicht im Online-Export sind
try {
const locals = await getLocalBooks()
const have = new Set(books.map((b) => b.asin))
books = [...books, ...locals.filter((l) => !have.has(l.asin))]
} catch {
// Scan optional
}
view = 'library'
} catch (e) {
const msg = String(e)
if (msg.toLowerCase().includes('encrypted')) {
// Auth-Datei verschlüsselt — Entschlüsselung im Terminal anbieten
error = 'Auth-Datei ist verschlüsselt. Bitte einmal entsprichern:'
error = 'Auth-Datei ist verschlüsselt. Bitte einmal entschließen:'
view = 'login'
} else {
error = msg
view = 'library'
books = []
// Offline-Modus: lokale Titel trotzdem anzeigen
try {
books = await getLocalBooks()
view = 'library'
info = 'Audible nicht erreichbar — zeige nur lokale Titel.'
} catch {
error = msg
view = 'library'
books = []
}
}
} finally {
checking = false
@ -250,7 +270,7 @@
<button class="ghost" onclick={() => checkAuth()} disabled={checking}>
{checking ? 'Prüfe…' : 'Jetzt prüfen'}
</button>
{#if error === 'Auth-Datei ist verschlüsselt. Bitte einmal entsprichern:'}
{#if error === 'Auth-Datei ist verschlüsselt. Bitte einmal entschließen:'}
<button class="ghost" onclick={() => startDecrypt().catch((e) => (error = String(e)))}>
Entschlüsseln im Terminal…
</button>
@ -281,6 +301,14 @@
<option value="runtime">Laufzeit</option>
<option value="percent">Fortschritt</option>
</select>
<button
class="ghost"
class:activechip={onlyLocal}
onclick={() => (onlyLocal = !onlyLocal)}
title="Nur lokal geladene Titel anzeigen"
>
{onlyLocal ? 'Nur lokale ✓' : 'Nur lokale'}
</button>
<button class="ghost" onclick={() => checkAuth()} disabled={checking}>
{checking ? '…' : 'Auffrischen'}
</button>
@ -320,8 +348,11 @@
<div class="t">{b.title}</div>
<div class="muted small">{b.authors}</div>
<div class="chips">
{#if isLocal(b)}<span class="chip ok" title="book.m4b liegt lokal vor">lokal</span>{/if}
{#if b.is_finished}<span class="chip done">fertig</span>{/if}
{#if isLocal(b)}
<span class="chip ok" title="book.m4b liegt lokal vor">lokal</span>
{:else if b.is_finished}
<span class="chip done">fertig</span>
{/if}
{#if b.runtime_length_min > 0}<span class="chip">{fmtRuntime(b.runtime_length_min)}</span>{/if}
{#if d && d.status === 'failed'}<span class="chip err" title={d.msg}>Fehlgeschlagen</span>{/if}
</div>
@ -334,7 +365,9 @@
<div class="progress indeterminate slow"><div class="fill"></div></div>
{/if}
<div class="actions">
{#if dlg === 'running' || dlg === 'queued' || dlg === 'decrypting'}
{#if isLocal(b)}
<button class="ghost" onclick={() => loeschen(b)}>Löschen</button>
{:else if dlg === 'running' || dlg === 'queued' || dlg === 'decrypting'}
<button class="ghost" onclick={() => abbrechen(b)}>
{dlg === 'queued' ? 'In der Queue — abbrechen?' : 'Abbrechen'}
</button>

View File

@ -173,6 +173,11 @@ button.ghost {
background: transparent;
}
button.activechip {
border-color: var(--ok);
color: var(--ok);
}
.info {
color: #7fa9d4;
}

View File

@ -24,6 +24,7 @@ export const authStatus = () => invoke<AuthStatus>('auth_status')
export const startLogin = () => invoke<boolean>('start_login')
export const startDecrypt = () => invoke<boolean>('start_decrypt')
export const getLibrary = () => invoke<Book[]>('get_library')
export const getLocalBooks = () => invoke<Book[]>('get_local_books')
export interface DlItem {
asin: string