T-012: Fix — Bibliothek async (spawn_blocking, kein UI-Freeze), Lade-Übergang, decrypt-Button für verschlüsselte Auth-Dateien
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { authStatus, startLogin, getLibrary, type Book } from './lib/audible'
|
||||
import { authStatus, startLogin, startDecrypt, getLibrary, type Book } from './lib/audible'
|
||||
|
||||
type View = 'loading' | 'login' | 'library'
|
||||
type SortKey = 'added' | 'title' | 'author' | 'runtime' | 'percent'
|
||||
@ -61,10 +61,16 @@
|
||||
books = await getLibrary()
|
||||
view = 'library'
|
||||
} catch (e) {
|
||||
// Fehler sichtbar machen, nicht in der Lade-Ansicht hängen
|
||||
error = String(e)
|
||||
view = 'library'
|
||||
books = []
|
||||
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 entschriften:'
|
||||
view = 'login'
|
||||
} else {
|
||||
error = msg
|
||||
view = 'library'
|
||||
books = []
|
||||
}
|
||||
} finally {
|
||||
checking = false
|
||||
loadingMsg = 'Prüfe Anmeldung…'
|
||||
@ -78,6 +84,7 @@
|
||||
const s = await authStatus()
|
||||
if (s.logged_in) {
|
||||
clearPoll()
|
||||
view = 'loading'
|
||||
loadingMsg = 'Lade Bibliothek…'
|
||||
await loadLibrary()
|
||||
} else if (view !== 'login') {
|
||||
@ -136,6 +143,11 @@
|
||||
<button class="ghost" onclick={() => checkAuth()} disabled={checking}>
|
||||
{checking ? 'Prüfe…' : 'Jetzt prüfen'}
|
||||
</button>
|
||||
{#if error === 'Auth-Datei ist verschlüsselt. Bitte einmal entschriften:'}
|
||||
<button class="ghost" onclick={() => startDecrypt().catch((e) => (error = String(e)))}>
|
||||
Entschlüsseln im Terminal…
|
||||
</button>
|
||||
{/if}
|
||||
{#if info}<p class="info">{info}</p>{/if}
|
||||
{#if error}<p class="error">{error}</p>{/if}
|
||||
</main>
|
||||
|
||||
@ -21,4 +21,5 @@ export interface Book {
|
||||
|
||||
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')
|
||||
|
||||
Reference in New Issue
Block a user