diff --git a/src/lib/pages/HistoryPage.svelte b/src/lib/pages/HistoryPage.svelte index 5ee93b5..0b72b18 100644 --- a/src/lib/pages/HistoryPage.svelte +++ b/src/lib/pages/HistoryPage.svelte @@ -8,7 +8,7 @@ import { PLAYBACK_SPEEDS, FEEDBACK_TIMEOUT_MS } from "$lib/utils/constants.js"; let searchQuery = $state(""); - let selectedItem = $state(null); + let expandedId = $state(null); let playingId = $state(null); let audioEl = $state(null); let currentTime = $state(0); @@ -37,12 +37,12 @@ function clearAll() { history.splice(0); saveHistory(); - selectedItem = null; + expandedId = null; stopPlayback(); } - function openItem(item) { - selectedItem = selectedItem === item ? null : item; + function toggleExpand(id) { + expandedId = expandedId === id ? null : id; } function copyItem(item) { @@ -53,7 +53,7 @@ const idx = history.indexOf(item); if (idx !== -1) { deleteFromHistory(idx); - if (selectedItem === item) selectedItem = null; + if (expandedId === item.id) expandedId = null; if (playingId === item.id) stopPlayback(); } } @@ -125,14 +125,11 @@ if (audioEl) audioEl.playbackRate = speed; } - async function openViewer(item) { - // Store item data for the viewer window try { localStorage.setItem("kon_viewer_item", JSON.stringify(item)); await invoke("open_viewer_window"); } catch { - // Fallback: open in browser tab (dev mode) localStorage.setItem("kon_viewer_item", JSON.stringify(item)); window.open("/viewer", "_blank", "width=600,height=700"); } @@ -181,7 +178,7 @@
- + {#if filtered.length === 0}
@@ -197,110 +194,147 @@

{:else} -
+
{#each filtered as item} +
openItem(item)} - onkeydown={(e) => { if (e.key === "Enter") openItem(item); }} + class="flex items-center gap-3 px-4 py-3 border-b border-border-subtle hover:bg-hover cursor-pointer transition-colors duration-150" + onclick={() => toggleExpand(item.id)} + onkeydown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); toggleExpand(item.id); } }} role="button" tabindex="0" + aria-expanded={expandedId === item.id} > -
- - {#if item.audioPath} - - {/if} - {#if item.title} - {item.title} - · - {/if} - {item.date} - · - {item.source} - {#if item.duration} - · {formatDuration(item.duration)} - {/if} -
- - {#if item.audioPath && item.segments && item.segments.length > 0} - - {/if} + + {#if item.audioPath} - - -
-

- {item.title ? item.text.slice(0, 120) : item.preview} -

- - {#if selectedItem === item} -
- - {#if item.audioPath && playingId === item.id} -
- - - {formatTime(currentTime)} / {formatTime(duration)} - - - e.stopPropagation()} - /> - -
- {#each PLAYBACK_SPEEDS as speed} - - {/each} -
-
+ class="w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 + {playingId === item.id ? 'bg-accent/20 text-accent' : 'bg-accent/10 text-accent hover:bg-accent/20'}" + onclick={(e) => { e.stopPropagation(); togglePlay(item); }} + aria-label={playingId === item.id && audioEl && !audioEl.paused ? "Pause" : "Play"} + > + {#if playingId === item.id && audioEl && !audioEl.paused} + + + + + {:else} + + + {/if} -

{item.text}

-
+ + {:else} + +
{/if} + + + + {item.title || item.preview || item.text.slice(0, 80)} + + + + {#if item.duration} + + {formatDuration(item.duration)} + + {/if} + + + + {#if item.source && item.source.toLowerCase().includes("file")} + + + + + + {:else} + + + + + + + + {/if} + + + + + {item.date} + + + + + +
+ + + {#if expandedId === item.id} +
+ + {#if item.audioPath && playingId === item.id} +
+ + {formatTime(currentTime)} / {formatTime(duration)} + + e.stopPropagation()} + /> +
+ {#each PLAYBACK_SPEEDS as speed} + + {/each} +
+
+ {/if} + + +

{item.text}

+ + +
+ + + {#if item.audioPath && item.segments && item.segments.length > 0} + + {/if} +
+ +
+
+ {/if} {/each}
{/if}