Import should refresh the password list.
This commit is contained in:
parent
0c908e8919
commit
289e8c9e34
@ -35,10 +35,11 @@
|
||||
loading = false
|
||||
}
|
||||
|
||||
// Reload when search query or active group filter changes
|
||||
// Reload when search query, active group filter, or refresh trigger changes
|
||||
$effect(() => {
|
||||
searchStore.query
|
||||
searchStore.activeGroupId
|
||||
searchStore.refreshTrigger
|
||||
loadEntries()
|
||||
})
|
||||
</script>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<script>
|
||||
import { exportAll, importAll } from '../lib/storage/db.js'
|
||||
import { search as searchStore } from '../lib/stores/search.svelte.js'
|
||||
|
||||
let showExport = $state(false)
|
||||
let showImport = $state(false)
|
||||
@ -49,6 +50,7 @@
|
||||
|
||||
const result = await importAll(data, importMode)
|
||||
importResult = result
|
||||
searchStore.refresh()
|
||||
} catch (e) {
|
||||
importError = 'Import failed: ' + e.message
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { getGroups, addGroup, updateGroup, deleteGroup, getEntryCountsByGroup } from '../lib/storage/db.js'
|
||||
import { createGroup, validateGroup } from '../lib/models/schema.js'
|
||||
import { search } from '../lib/stores/search.svelte.js'
|
||||
import { search as searchStore } from '../lib/stores/search.svelte.js'
|
||||
|
||||
let groups = $state([])
|
||||
let entryCounts = $state(new Map())
|
||||
@ -26,7 +26,12 @@
|
||||
groups = g
|
||||
entryCounts = counts
|
||||
}
|
||||
loadData()
|
||||
|
||||
// Initial load + refresh after import/export
|
||||
$effect(() => {
|
||||
searchStore.refreshTrigger
|
||||
loadData()
|
||||
})
|
||||
|
||||
function openGroupForm(group = null) {
|
||||
if (group) {
|
||||
@ -69,8 +74,8 @@
|
||||
async function confirmDeleteGroup(groupId) {
|
||||
try {
|
||||
await deleteGroup(groupId)
|
||||
if (search.activeGroupId === groupId) {
|
||||
search.activeGroupId = 'all'
|
||||
if (searchStore.activeGroupId === groupId) {
|
||||
searchStore.activeGroupId = 'all'
|
||||
}
|
||||
showDeleteGroupConfirm = null
|
||||
await loadData()
|
||||
@ -89,15 +94,15 @@
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search entries..."
|
||||
value={search.query}
|
||||
onInput={(e) => search.query = e.target.value}
|
||||
value={searchStore.query}
|
||||
onInput={(e) => searchStore.query = e.target.value}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<nav class="groups-nav">
|
||||
<button
|
||||
class="group-item {search.activeGroupId === 'all' ? 'active' : ''}"
|
||||
onclick={() => search.activeGroupId = 'all'}
|
||||
class="group-item {searchStore.activeGroupId === 'all' ? 'active' : ''}"
|
||||
onclick={() => searchStore.activeGroupId = 'all'}
|
||||
>
|
||||
<span class="group-icon">📋</span>
|
||||
<span class="group-name">All Entries</span>
|
||||
@ -106,8 +111,8 @@
|
||||
{#each groups as group}
|
||||
<div class="group-row">
|
||||
<button
|
||||
class="group-item {search.activeGroupId === group.id ? 'active' : ''}"
|
||||
onclick={() => search.activeGroupId = group.id}
|
||||
class="group-item {searchStore.activeGroupId === group.id ? 'active' : ''}"
|
||||
onclick={() => searchStore.activeGroupId = group.id}
|
||||
>
|
||||
<span class="group-color" style="background-color: {group.color || '#6c63ff'}"></span>
|
||||
<span class="group-name">{group.name}</span>
|
||||
|
||||
@ -6,11 +6,17 @@
|
||||
export class SearchStore {
|
||||
query = $state('')
|
||||
activeGroupId = $state('all') // 'all' or a group id
|
||||
refreshTrigger = $state(0) // incremented to force a re-fetch
|
||||
|
||||
clear() {
|
||||
this.query = ''
|
||||
this.activeGroupId = 'all'
|
||||
}
|
||||
|
||||
/** Force subscribed components to re-fetch data. */
|
||||
refresh() {
|
||||
this.refreshTrigger++
|
||||
}
|
||||
}
|
||||
|
||||
export const search = new SearchStore()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user