refactor(journals): stabilize reactive search and synchronize result counts

- Refactored 'src/routes/journals/[journal_id]/+page.svelte' to use a singleton 'liveQuery' observable, eliminating the search subscription loop.
- Synchronized entry counts in 'ae_comp__journal_obj_id_view.svelte' with the shared entries observable, ensuring accurate header feedback.
- Cleaned up 'ae_comp__journal_entry_obj_li.svelte' by removing redundant script blocks and hardening visibility filters.
- Restricted the result count badge to Edit Mode for a cleaner standard user interface.
- Improved initial load UX with localized spinners and proper undefined-state guards.
This commit is contained in:
Scott Idem
2026-01-27 16:17:46 -05:00
parent 6055fc3408
commit 4f8c482cf3
4 changed files with 137 additions and 90 deletions

View File

@@ -3,7 +3,7 @@
import { goto } from '$app/navigation';
// *** Import other supporting libraries
import { BookPlus, BookOpenText, FilePlus, Menu, Pencil, FileDown, FileUp, Settings } from 'lucide-svelte';
import { BookPlus, BookOpenText, FilePlus, Menu, Pencil, FileDown, FileUp, Settings, LoaderCircle } from 'lucide-svelte';
// *** Import Aether specific variables and functions
import { ae_util } from '$lib/ae_utils/ae_utils';
@@ -68,11 +68,11 @@
}
return;
}
// Use journal.passcode_timeout (assuming it's in minutes, default to 5)
const timeout_minutes = $lq__journal_obj?.passcode_timeout ?? 5;
const timeout_ms = 1000 * 60 * timeout_minutes;
if (log_lvl) {
console.log(`Setting passcode timer for ${timeout_minutes} minutes (${timeout_ms}ms)`);
}
@@ -86,11 +86,11 @@
if (!$journals_sess?.journal_kv[$lq__journal_obj?.id]) {
$journals_sess.journal_kv[$lq__journal_obj?.id] = {};
}
// Reset verification and decryption flags
$journals_sess.journal_kv[$lq__journal_obj?.id].journal_passcode_verified = false;
$journals_sess.journal_kv[$lq__journal_obj?.id].journal_passcode_decrypted = false;
passcode_timer = null;
},
timeout_ms
@@ -127,7 +127,7 @@
if ($journals_loc.entry.qry__category_code) {
data_kv.category_code = $journals_loc.entry.qry__category_code;
}
try {
const results = await journals_func.create_ae_obj__journal_entry({
api_cfg: $ae_api,
@@ -135,7 +135,7 @@
data_kv: data_kv,
log_lvl: log_lvl
});
if (results?.journal_entry_id_random) {
$journals_slct.journal_entry_id = results.journal_entry_id_random;
$journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] = 'current';
@@ -163,13 +163,18 @@
<h2 class="journal__name h3 text-center">
<BookOpenText class="inline-block text-neutral-800/60" />
{@html $lq__journal_obj?.name ?? 'Loading...'}
{#if $ae_loc.trusted_access && $ae_loc.edit_mode}
({$lq__journal_entry_obj_li?.length ?? '0'}×)
{#if $ae_loc.edit_mode}
<span
class="badge preset-tonal-success font-bold text-lg px-2 ml-2"
title="Entries matching current filters"
>
{$lq__journal_entry_obj_li?.length ?? '0'}<span class="text-xs opacity-50 ml-0.5">&times;</span>
</span>
{/if}
{#await $journals_prom.load__journal_entry_obj_li}
<span class="fas fa-spinner fa-spin"></span>
{:then}
<!-- done -->
<LoaderCircle size="1em" class="inline-block animate-spin ml-1 text-primary-500" />
{/await}
</h2>