Feedback-Runde: lokale Titel sofort beim Start (ffprobe-Scan vor Online-Laden), Löschen-Bug (Vorexist-Check), Nur-Streaming-Merkliste mit ▶-Button statt Download
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
startDecrypt,
|
||||
getLibrary,
|
||||
getLocalBooks,
|
||||
getStreamOnly,
|
||||
downloadList,
|
||||
downloadEnqueue,
|
||||
downloadCancel,
|
||||
@ -32,6 +33,7 @@
|
||||
let downloads = $state<Record<string, DlItem>>({})
|
||||
let loadedOverride = $state<Record<string, boolean>>({})
|
||||
let removedLocals = $state<Record<string, boolean>>({})
|
||||
let streamOnly = $state<Record<string, boolean>>({})
|
||||
|
||||
const actives = $derived.by(() => {
|
||||
let n = 0
|
||||
@ -140,16 +142,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
function mergeBooks(incoming: Book[]) {
|
||||
const have = new Set(books.map((b) => b.asin))
|
||||
const extra = incoming.filter((b) => !have.has(b.asin))
|
||||
if (extra.length) books = [...books, ...extra]
|
||||
return books
|
||||
}
|
||||
|
||||
async function loadLibrary(): Promise<void> {
|
||||
checking = true
|
||||
error = ''
|
||||
try {
|
||||
books = await getLibrary()
|
||||
// Lokale Titel einpflügen, die (noch) nicht im Online-Export sind
|
||||
const online = await getLibrary()
|
||||
books = online
|
||||
// Lokale Titel einpflegen, 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))]
|
||||
mergeBooks(await getLocalBooks())
|
||||
} catch {
|
||||
// Scan optional
|
||||
}
|
||||
@ -161,11 +169,12 @@
|
||||
error = 'Auth-Datei ist verschlüsselt. Bitte einmal entschließen:'
|
||||
view = 'login'
|
||||
} else {
|
||||
// Offline-Modus: lokale Titel trotzdem anzeigen
|
||||
// Offline-Modus: lokale Titel trotzdem anzeigen (falls vorhanden)
|
||||
try {
|
||||
books = await getLocalBooks()
|
||||
const locals = await getLocalBooks()
|
||||
books = locals.length ? [...books.filter((b) => b.local), ...locals] : locals
|
||||
view = 'library'
|
||||
info = 'Audible nicht erreichbar — zeige nur lokale Titel.'
|
||||
info = 'Audible nicht erreichbar — zeige lokale Titel.'
|
||||
} catch {
|
||||
error = msg
|
||||
view = 'library'
|
||||
@ -185,6 +194,18 @@
|
||||
const s = await authStatus()
|
||||
if (s.logged_in) {
|
||||
clearPoll()
|
||||
// Sofort die lokalen Titel zeigen (schnell, ohne Netz),
|
||||
// danach Online-Daten still ergänzen.
|
||||
loadingMsg = 'Suche lokale Titel…'
|
||||
try {
|
||||
const locals = await getLocalBooks()
|
||||
if (locals.length) {
|
||||
books = locals
|
||||
view = 'library'
|
||||
}
|
||||
} catch {
|
||||
// kein Bücherordner — weiter mit 'Lade Bibliothek…'
|
||||
}
|
||||
view = 'loading'
|
||||
loadingMsg = 'Lade Bibliothek…'
|
||||
await loadLibrary()
|
||||
@ -226,6 +247,9 @@
|
||||
loadedOverride = { ...loadedOverride, [it.asin]: true }
|
||||
info = `Download fertig: ${it.asin}`
|
||||
}
|
||||
if (it.status === 'failed' && it.msg.includes('nicht als Datei')) {
|
||||
streamOnly = { ...streamOnly, [it.asin]: true }
|
||||
}
|
||||
})
|
||||
// Abgleich: Events können bei App-Neustart/HMR verlorengehen — der
|
||||
// periodische Abgleich macht den Backend-Stand zur Autorität.
|
||||
@ -367,6 +391,14 @@
|
||||
<div class="actions">
|
||||
{#if isLocal(b)}
|
||||
<button class="ghost" onclick={() => loeschen(b)}>Löschen</button>
|
||||
{:else if streamOnly[b.asin]}
|
||||
<button
|
||||
class="ghost"
|
||||
onclick={() => (info = 'Wiedergabe folgt mit M2 — diesen Titel liefert Audible nur zum Streamen.')}
|
||||
>
|
||||
▶ Abspielen
|
||||
</button>
|
||||
<span class="muted small">nur Streaming</span>
|
||||
{:else if dlg === 'running' || dlg === 'queued' || dlg === 'decrypting'}
|
||||
<button class="ghost" onclick={() => abbrechen(b)}>
|
||||
{dlg === 'queued' ? 'In der Queue — abbrechen?' : 'Abbrechen'}
|
||||
|
||||
Reference in New Issue
Block a user