fix(idaa): resolve BB comment loop and parent mapping issues
- Switched to create_nested_obj_v3 for establishing parent-child links. - Optimized background load trigger with untrack to prevent infinite loops. - Resolved MySQL IntegrityError (missing post_id) during comment creation. - Hardened view component reactivity for Svelte 5.
This commit is contained in:
@@ -145,6 +145,7 @@ export async function load_ae_obj_li__post_comment({
|
|||||||
// Updated 2026-01-06
|
// Updated 2026-01-06
|
||||||
export async function create_ae_obj__post_comment({
|
export async function create_ae_obj__post_comment({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
|
account_id,
|
||||||
post_id,
|
post_id,
|
||||||
data_kv,
|
data_kv,
|
||||||
params = {},
|
params = {},
|
||||||
@@ -152,6 +153,7 @@ export async function create_ae_obj__post_comment({
|
|||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any;
|
api_cfg: any;
|
||||||
|
account_id: string;
|
||||||
post_id: string;
|
post_id: string;
|
||||||
data_kv: key_val;
|
data_kv: key_val;
|
||||||
params?: key_val;
|
params?: key_val;
|
||||||
@@ -159,14 +161,16 @@ export async function create_ae_obj__post_comment({
|
|||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}): Promise<ae_PostComment | null> {
|
}): Promise<ae_PostComment | null> {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`*** create_ae_obj__post_comment() *** post_id=${post_id}`);
|
console.log(`*** create_ae_obj__post_comment() *** account_id=${account_id} post_id=${post_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await api.create_ae_obj_v3({
|
const result = await api.create_nested_obj_v3({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type: 'post_comment',
|
parent_type: 'post',
|
||||||
|
parent_id: post_id,
|
||||||
|
child_type: 'post_comment',
|
||||||
fields: {
|
fields: {
|
||||||
post_id_random: post_id,
|
account_id: account_id,
|
||||||
...data_kv
|
...data_kv
|
||||||
},
|
},
|
||||||
params,
|
params,
|
||||||
|
|||||||
@@ -30,16 +30,15 @@
|
|||||||
import Comp__post_comment_obj_id_edit from './ae_idaa_comp__post_comment_obj_id_edit.svelte';
|
import Comp__post_comment_obj_id_edit from './ae_idaa_comp__post_comment_obj_id_edit.svelte';
|
||||||
import AE_Comp_Hosted_Files_Download_Button from '$lib/ae_core/ae_comp__hosted_files_download_button.svelte';
|
import AE_Comp_Hosted_Files_Download_Button from '$lib/ae_core/ae_comp__hosted_files_download_button.svelte';
|
||||||
|
|
||||||
let ae_promises: key_val = $state({});
|
import { untrack } from 'svelte';
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
const post_id = $idaa_slct.post_id;
|
const post_id = $idaa_slct.post_id;
|
||||||
if (post_id) {
|
if (post_id && post_id !== untrack(() => $idaa_trig.post_id)) {
|
||||||
if (log_lvl) {
|
if (log_lvl) {
|
||||||
console.log(`Post ID selected: ${post_id}`);
|
console.log(`Post ID selected: ${post_id}`);
|
||||||
console.log(`Post Object selected: `, $lq__post_obj);
|
|
||||||
}
|
}
|
||||||
// Trigger background load
|
// Trigger background load only if it's a new ID
|
||||||
$idaa_trig.post_id = post_id;
|
$idaa_trig.post_id = post_id;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user