From 173dc3c84c65c26a5d4a781be9967944459a1d7d Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Mon, 9 Mar 2026 17:53:35 -0400 Subject: [PATCH] fix(idaa/bb): fire-and-forget page load + UX fixes for post/comment editing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - [post_id]/+page.ts: remove await on post load (same pattern as archives); liveQuery renders immediately, replace error(404) with console.warn. - ae_idaa_comp__post_options: add in-flight creating guard + spinner on Create New Post button to prevent double-submit; remove ~15 lines of dead commented code left over from previous refactors. - ae_idaa_comp__post_obj_id_view: remove confirm() dialog before opening the Add Comment form — no need to confirm an intent to type a comment. - ae_idaa_comp__post_comment_obj_id_edit: remove redundant block that manually injected post_id into the payload for new comments; post_id is already handled correctly by the form payload builder. --- src/routes/idaa/(idaa)/bb/[post_id]/+page.ts | 19 ++++-------- ...idaa_comp__post_comment_obj_id_edit.svelte | 9 +----- .../bb/ae_idaa_comp__post_obj_id_view.svelte | 5 ---- .../bb/ae_idaa_comp__post_options.svelte | 30 +++++++------------ 4 files changed, 18 insertions(+), 45 deletions(-) diff --git a/src/routes/idaa/(idaa)/bb/[post_id]/+page.ts b/src/routes/idaa/(idaa)/bb/[post_id]/+page.ts index 7f6ba1bc..ae388c5b 100644 --- a/src/routes/idaa/(idaa)/bb/[post_id]/+page.ts +++ b/src/routes/idaa/(idaa)/bb/[post_id]/+page.ts @@ -2,7 +2,6 @@ import type { PageLoad } from './$types'; console.log(`ae_idaa_bulletin_board [post_id] +page.ts start`); -import { error } from '@sveltejs/kit'; import { browser } from '$app/environment'; import { posts_func } from '$lib/ae_posts/ae_posts_functions'; @@ -24,8 +23,11 @@ export const load = (async ({ params, parent }) => { if (log_lvl) { console.log(`ae_idaa_posts posts [post_id] +page.ts: post_id = `, post_id); } - // Load post object - const load_post_obj = await posts_func + // NOTE: Fire in background — do NOT await. Newly created posts are already in Dexie + // (saved by create_ae_obj__post), so the liveQuery renders immediately. For direct + // links or refreshes, the post loads from the API and Dexie updates reactively. + // Awaiting here blocked the SvelteKit navigation, causing a visible "refresh" delay. + posts_func .load_ae_obj_id__post({ api_cfg: ae_acct.api, post_id: post_id, @@ -34,18 +36,9 @@ export const load = (async ({ params, parent }) => { }) .then((results) => { if (!results) { - error(404, { - message: 'IDAA BB - Post not found' - }); - } else { - // ae_acct.slct.post_obj = results; + console.warn(`ae IDAA BB [post_id] +page.ts: Post ${post_id} not found via API or Cache.`); } }); - - if (log_lvl) { - console.log(`load_post_obj = `, load_post_obj); - } - ae_acct.slct.post_obj = load_post_obj; } // WARNING: Precaution against shared data between sites. diff --git a/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_comment_obj_id_edit.svelte b/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_comment_obj_id_edit.svelte index d5ac551d..784468dc 100644 --- a/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_comment_obj_id_edit.svelte +++ b/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_comment_obj_id_edit.svelte @@ -105,13 +105,6 @@ post_comment_do['group'] = post_comment_form.group ?? null; post_comment_do['enable'] = post_comment_form.enable ?? true; - if (!$idaa_slct.post_comment_id) { - // NEW COMMENT: Ensure post_id is included - const parent_post_id = $idaa_slct.post_id; - post_comment_do['post_id'] = parent_post_id; - // post_comment_do['post_id'] = parent_post_id; - } - log_lvl = 1; if (log_lvl) { console.log('Final Payload (post_comment_do):', post_comment_do); @@ -819,7 +812,7 @@ Copy and paste link: ${ type="submit" disabled={disable_submit_btn} onclick={() => { - if (!confirm('Are you sure you want to create this post?')) { + if (!confirm('Are you sure you want to add this comment?')) { return false; } // handle_save_post_comment_obj({post_id: $idaa_slct.post_id, method: 'create'}); diff --git a/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_id_view.svelte b/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_id_view.svelte index b8566d48..f23c7c36 100644 --- a/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_id_view.svelte +++ b/src/routes/idaa/(idaa)/bb/ae_idaa_comp__post_obj_id_view.svelte @@ -161,13 +161,8 @@ {#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || $idaa_loc.novi_uuid} {/if}