From d3f71be94eb8b15dc3cf920c7addd2e509fa7146 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 12 Aug 2025 12:02:46 -0400 Subject: [PATCH] Minor update to make the selected Post Comment update when the liveQuery value changes. --- src/routes/idaa/(idaa)/bb/[post_id]/+page.svelte | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/routes/idaa/(idaa)/bb/[post_id]/+page.svelte b/src/routes/idaa/(idaa)/bb/[post_id]/+page.svelte index e97ca58c..36579cd4 100644 --- a/src/routes/idaa/(idaa)/bb/[post_id]/+page.svelte +++ b/src/routes/idaa/(idaa)/bb/[post_id]/+page.svelte @@ -88,7 +88,20 @@ let lq__post_comment_obj = $derived(liveQuery(async () => { let results = await db_posts.comment .get($idaa_slct.post_comment_id ?? ''); // null or undefined does not reset things like '' does - $idaa_slct.post_comment_obj = { ...results }; + // Check if results are different than the current $idaa_slct.post_comment_obj + if ($idaa_slct.post_comment_obj && results) { + if (JSON.stringify($idaa_slct.post_comment_obj) !== JSON.stringify(results)) { + $idaa_slct.post_comment_obj = { ...results }; + if (log_lvl) { + console.log(`$idaa_slct.post_comment_obj = `, $idaa_slct.post_comment_obj); + } + } else { + if (log_lvl) { + console.log(`Post comment object has not changed for post_comment_id: ${$idaa_slct.post_comment_id}`); + } + } + } + return results; }));