refactor(journals): standardize high-performance reactive search and stabilize results stream

- Implemented the loop-proof search pattern in 'src/routes/journals/[journal_id]/+page.svelte' using versioned triggers and untracked dependency isolation.
- Stabilized data loading by introducing 'ae_comp__journal_entry_obj_li_wrapper.svelte', ensuring smooth SWR transitions between local and API results.
- Synchronized result counts with the rendered list in 'ae_comp__journal_entry_obj_li.svelte' and implemented permissive visibility defaults.
- Added 'Remote First' toggle support (Edit Mode only) and laid groundwork for Global Search in 'ae_comp__journal_entry_obj_qry.svelte'.
- Updated Dexie schema and API helpers to support future person-level cross-journal searching.
This commit is contained in:
Scott Idem
2026-01-27 15:20:17 -05:00
parent 07e13ea5f2
commit 6055fc3408
7 changed files with 367 additions and 477 deletions

View File

@@ -71,11 +71,46 @@
function handle_modal_update() {
handle_modal_close();
}
// Derived list of visible items (Standardized Search Pattern 2026-01-27)
// Ensures count matches exactly what is rendered to the user
let visible_journal_entry_obj_li = $derived((() => {
const list = $lq__journal_entry_obj_li;
if (!list || !Array.isArray(list)) return [];
const filtered = list.filter((item: any) => {
if (!item) return false;
// ADMIN/TRUSTED: See everything
if ($ae_loc.trusted_access) return true;
// PUBLIC: Filter hidden/disabled
// Permissive defaults for missing metadata
const is_hidden = item.hide === true || item.hide === 1;
const is_disabled = item.enable === false || item.enable === 0;
return !is_hidden && !is_disabled;
});
if (log_lvl) console.log(`visible_journal_entry_obj_li: Input=${list.length}, Output=${filtered.length}`);
return filtered;
})());
</script>
<section class="journal_list flex flex-col gap-1 md:gap-2 items-center justify-center w-full">
{#if $lq__journal_entry_obj_li && $lq__journal_entry_obj_li.length}
{#each $lq__journal_entry_obj_li as journals_journal_entry_obj, index}
{#if visible_journal_entry_obj_li && visible_journal_entry_obj_li.length}
<div class="w-full max-w-(--breakpoint-lg) mb-2">
<h2 class="h4 flex items-center gap-2 px-2">
<span class="text-sm text-gray-500 font-normal"> Found: </span>
<span class="badge preset-tonal-success font-bold text-lg px-3 py-1">
{visible_journal_entry_obj_li.length}<span class="text-gray-400 dark:text-gray-600">&times;</span>
</span>
</h2>
</div>
{#each visible_journal_entry_obj_li as journals_journal_entry_obj, index}
<div
class="
container journal journal_entry_obj
@@ -359,7 +394,8 @@
$journals_loc.entry.qry__category_code =
journals_journal_entry_obj.category_code;
}
$journals_trig.journal_entry_li = true;
if ($journals_loc.entry.search_version === undefined) $journals_loc.entry.search_version = 0;
$journals_loc.entry.search_version++;
}}
class:bg-green-100={$journals_loc.entry.qry__category_code ==
journals_journal_entry_obj.category_code}