Altersangaben: Genre-Signal-Chip (Kinder/Jugend aus Audible-Genres) + manuelle Altersnote pro Buch (labels.json, Inline-Edit mit Stift-Button)
This commit is contained in:
@ -6,6 +6,8 @@
|
||||
getLibrary,
|
||||
getLocalBooks,
|
||||
getStreamOnly,
|
||||
getAlterNotes,
|
||||
setAlterNote,
|
||||
downloadList,
|
||||
downloadEnqueue,
|
||||
downloadCancel,
|
||||
@ -35,6 +37,40 @@
|
||||
let loadedOverride = $state<Record<string, boolean>>({})
|
||||
let removedLocals = $state<Record<string, boolean>>({})
|
||||
let streamOnly = $state<Record<string, boolean>>({})
|
||||
let alterNotes = $state<Record<string, string>>({})
|
||||
let editingAlter = $state<string | null>(null)
|
||||
let alterDraft = $state('')
|
||||
|
||||
function ageTag(b: Book): 'Kinder' | 'Jugend' | null {
|
||||
const g = (b.genres || '').toLowerCase()
|
||||
if (g.includes('kinder')) return 'Kinder'
|
||||
if (g.includes('jugend')) return 'Jugend'
|
||||
return null
|
||||
}
|
||||
|
||||
function alterNote(b: Book): string {
|
||||
return alterNotes[b.asin] ?? ''
|
||||
}
|
||||
|
||||
function startEditAlter(b: Book): void {
|
||||
editingAlter = b.asin
|
||||
alterDraft = alterNote(b)
|
||||
}
|
||||
|
||||
async function saveAlter(b: Book): Promise<void> {
|
||||
try {
|
||||
await setAlterNote(b.asin, alterDraft.trim() || null)
|
||||
alterNotes = { ...alterNotes, [b.asin]: alterDraft.trim() }
|
||||
if (!alterDraft.trim()) {
|
||||
const rest = { ...alterNotes }
|
||||
delete rest[b.asin]
|
||||
alterNotes = rest
|
||||
}
|
||||
editingAlter = null
|
||||
} catch (e) {
|
||||
error = String(e)
|
||||
}
|
||||
}
|
||||
|
||||
const actives = $derived.by(() => {
|
||||
let n = 0
|
||||
@ -256,6 +292,9 @@
|
||||
// periodische Abgleich macht den Backend-Stand zur Autorität.
|
||||
const syncId = setInterval(syncDownloads, 3000)
|
||||
syncDownloads()
|
||||
getAlterNotes()
|
||||
.then((all) => (alterNotes = all))
|
||||
.catch(() => {})
|
||||
return () => {
|
||||
clearPoll()
|
||||
clearInterval(syncId)
|
||||
@ -381,6 +420,11 @@
|
||||
{#if b.is_finished && !isLocal(b)}
|
||||
<span class="chip done" title="Buch abgehört"><Icon name="play" size={12} /> fertig</span>
|
||||
{/if}
|
||||
{#if alterNote(b)}
|
||||
<span class="chip age" title="Manuelle Altersnote">{alterNote(b)}</span>
|
||||
{:else if ageTag(b)}
|
||||
<span class="chip" title="Audible-Genre (Hinweis, keine Altersfreigabe)">{ageTag(b)}</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>
|
||||
@ -393,8 +437,20 @@
|
||||
<div class="progress indeterminate slow"><div class="fill"></div></div>
|
||||
{/if}
|
||||
<div class="actions">
|
||||
{#if isLocal(b)}
|
||||
<button class="ghost" onclick={() => loeschen(b)}>Löschen</button>
|
||||
{#if editingAlter === b.asin}
|
||||
<input
|
||||
class="input"
|
||||
placeholder="z. B. ab 6"
|
||||
bind:value={alterDraft}
|
||||
onkeydown={(e) => e.key === 'Enter' && saveAlter(b)}
|
||||
/>
|
||||
<button class="primary" onclick={() => saveAlter(b)}>Speichern</button>
|
||||
<button class="ghost" onclick={() => (editingAlter = null)}><Icon name="x" size={13} /></button>
|
||||
{:else if isLocal(b)}
|
||||
<button class="ghost" onclick={() => loeschen(b)}><Icon name="trash" size={14} /> Löschen</button>
|
||||
<button class="ghost" title="Altersnote setzen" onclick={() => startEditAlter(b)}>
|
||||
<Icon name="pencil" size={13} /> Alter
|
||||
</button>
|
||||
{:else if streamOnly[b.asin]}
|
||||
<button
|
||||
class="ghost"
|
||||
|
||||
11
src/app.css
11
src/app.css
@ -275,6 +275,17 @@ button.activechip {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.chip.age {
|
||||
color: var(--ok);
|
||||
border-color: var(--ok);
|
||||
}
|
||||
|
||||
.actions input.input {
|
||||
width: 7rem;
|
||||
font-size: 0.85rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 3px;
|
||||
border-radius: 2px;
|
||||
|
||||
@ -8,6 +8,8 @@
|
||||
trash:
|
||||
'<path d="M4 7h16"/><path d="M9 7V4h6v3"/><path d="M6.5 7l1 14h9l1-14"/>',
|
||||
play: '<path d="M8 5v14l11-7z" fill="currentColor" stroke="none"/>',
|
||||
pencil:
|
||||
'<path d="M4 20h4L20 8l-4-4L4 16v4z"/><path d="M13.5 6.5l4 4"/>',
|
||||
x: '<path d="M5 5l14 14"/><path d="M19 5 5 19"/>',
|
||||
}
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@ export interface Book {
|
||||
percent_complete: number
|
||||
is_finished: boolean
|
||||
date_added: string
|
||||
genres: string
|
||||
local: boolean
|
||||
}
|
||||
|
||||
@ -26,6 +27,9 @@ export const startDecrypt = () => invoke<boolean>('start_decrypt')
|
||||
export const getLibrary = () => invoke<Book[]>('get_library')
|
||||
export const getLocalBooks = () => invoke<Book[]>('get_local_books')
|
||||
export const getStreamOnly = () => invoke<string[]>('stream_only')
|
||||
export const getAlterNotes = () => invoke<Record<string, string>>('get_alter_notes')
|
||||
export const setAlterNote = (asin: string, note: string | null) =>
|
||||
invoke<void>('set_alter_note', { asin, note })
|
||||
|
||||
export interface DlItem {
|
||||
asin: string
|
||||
|
||||
Reference in New Issue
Block a user