From 05d7e784443499765fbbe38a8dc3c26d2b7e4665 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 12 Aug 2025 14:19:54 -0400 Subject: [PATCH] Bug fixes --- .../(idaa)/archives/[archive_id]/+page.svelte | 93 +++++++++---------- ...e_idaa_comp__archive_content_obj_li.svelte | 12 +-- 2 files changed, 51 insertions(+), 54 deletions(-) diff --git a/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte index 2760589e..7f72b707 100644 --- a/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte +++ b/src/routes/idaa/(idaa)/archives/[archive_id]/+page.svelte @@ -47,7 +47,7 @@ import Help_tech from '$lib/e_app_help_tech.svelte'; // if (!archive_content_id) { // $idaa_slct.archive_content_id = null; // } else { -// console.log(`ae Posts - [archive_content_id] +page.ts: archive_content_id = `, archive_content_id); +// console.log(`ae Archives - [archive_content_id] +page.ts: archive_content_id = `, archive_content_id); // $idaa_slct.archive_content_id = archive_content_id; // $idaa_trig.archive_content_id = archive_content_id; // } @@ -109,6 +109,18 @@ let lq__archive_content_obj_li = $derived(liveQuery(async () => { // .reverse() .sortBy('tmp_sort_1'); + + if ($idaa_slct.archive_content_obj_li && JSON.stringify($idaa_slct.archive_content_obj_li) !== JSON.stringify(results)) { + $idaa_slct.archive_content_obj_li = [...results]; + if (log_lvl) { + console.log(`$idaa_slct.archive_content_obj_li = `, $idaa_slct.archive_content_obj_li); + } + } else { + if (log_lvl) { + console.log(`Archive content object list has not changed for archive_id: ${$idaa_slct.archive_id}`); + } + } + return results; } @@ -118,16 +130,26 @@ let lq__archive_content_obj = $derived(liveQuery(async () => { if (log_lvl) { console.log(`lq__archive_content_obj: archive_content_id = ${$idaa_slct?.archive_content_id}`); } - if ($idaa_slct.archive_content_id) { + // if ($idaa_slct.archive_content_id) { let results = await db_archives.content - .get($idaa_slct.archive_content_id); // null or undefined does not reset things like '' does + .get($idaa_slct.archive_content_id ?? ''); // null or undefined does not reset things like '' does + + // Check if results are different than the current $idaa_slct.archive_content_obj + if ($idaa_slct.archive_content_obj && results) { + if (JSON.stringify($idaa_slct.archive_content_obj) !== JSON.stringify(results)) { + $idaa_slct.archive_content_obj = { ...results }; + if (log_lvl) { + console.log(`$idaa_slct.archive_content_obj = `, $idaa_slct.archive_content_obj); + } + } else { + if (log_lvl) { + console.log(`Archive content object has not changed for archive_content_id: ${$idaa_slct.archive_content_id}`); + } + } + } return results; - } - // const results = await db_archives.content - // .get($idaa_slct.archive_content_id); // null or undefined does not reset things like '' does - - // return results; + // } })); @@ -386,9 +408,10 @@ onDestroy(() => { + + { {/if} - Edit Archive Content: + Edit Content: - {$lq__archive_content_obj?.name ?? 'New Archive Content'} + {$idaa_slct.archive_content_obj?.name ?? 'New Archive Content'} @@ -447,38 +473,9 @@ onDestroy(() => { {/snippet} + - - - - - +interface Props { + lq__archive_content_obj_li: any; +} + +let { lq__archive_content_obj_li }: Props = $props(); + // *** Import Svelte specific import { goto, invalidate, pushState, replaceState } from '$app/navigation'; @@ -9,12 +15,6 @@ import { api } from '$lib/api'; import { ae_snip, ae_loc, ae_sess, ae_api, ae_trig, slct, slct_trigger } from '$lib/ae_stores'; import { idaa_loc, idaa_sess, idaa_slct } from '$lib/ae_idaa_stores'; -interface Props { - lq__archive_content_obj_li: any; -} - -let { lq__archive_content_obj_li }: Props = $props(); - let ae_promises: key_val = $state({}); // let ae_tmp: key_val = {}; // let ae_triggers: key_val = {};