feat(v3): harden clean ID pattern and standardize snake_case platform-wide
- Systematically migrated from *_id_random to clean *_id fields in BB, People, and Posts modules. - Synchronized Post_Comment interface with account_id for multi-tenant isolation. - Applied optional chaining and local reactive state to harden async UI initialization. - Refactored common helpers to follow snake_case naming conventions. - Resolved various minor stability and logic issues across IDAA Bulletin Board.
This commit is contained in:
@@ -107,18 +107,18 @@
|
||||
log_lvl: 1
|
||||
});
|
||||
// Filter users that don't have a person_id linked
|
||||
// NOTE: The backend might return person_id or person_id_random
|
||||
available_users = all_users.filter(u => !u.person_id_random && !u.person_id);
|
||||
// NOTE: The backend might return person_id or person_id
|
||||
available_users = all_users.filter(u => !u.person_id && !u.person_id);
|
||||
loading_users = false;
|
||||
}
|
||||
|
||||
async function handle_link_user(user_id_random: string) {
|
||||
async function handle_link_user(user_id: string) {
|
||||
if (!confirm('Link this person to this user account?')) return;
|
||||
|
||||
const result = await update_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
person_id: $slct.person_id,
|
||||
data_kv: { user_id_random },
|
||||
data_kv: { user_id },
|
||||
log_lvl: 1
|
||||
});
|
||||
|
||||
@@ -134,7 +134,7 @@
|
||||
const result = await update_ae_obj__person({
|
||||
api_cfg: $ae_api,
|
||||
person_id: $slct.person_id,
|
||||
data_kv: { user_id_random: null },
|
||||
data_kv: { user_id: null },
|
||||
log_lvl: 1
|
||||
});
|
||||
}
|
||||
@@ -252,7 +252,7 @@
|
||||
<ShieldCheck size={18} />
|
||||
<span>User Account Linking</span>
|
||||
</div>
|
||||
{#if $lq__person_obj?.user_id_random}
|
||||
{#if $lq__person_obj?.user_id}
|
||||
<button class="btn btn-sm variant-soft-error" onclick={handle_unlink_user}>
|
||||
<Unlink size={14} class="mr-2" /> Unlink User
|
||||
</button>
|
||||
@@ -266,14 +266,14 @@
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
{#if $lq__person_obj?.user_id_random}
|
||||
{#if $lq__person_obj?.user_id}
|
||||
<div class="flex items-center gap-4 py-2">
|
||||
<div class="avatar variant-filled-primary w-12 h-12 flex items-center justify-center rounded-full">
|
||||
<Users size={24} />
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-sm opacity-60 uppercase tracking-widest font-bold">Linked User ID</p>
|
||||
<p class="font-mono text-lg">{$lq__person_obj.user_id_random}</p>
|
||||
<p class="font-mono text-lg">{$lq__person_obj.user_id}</p>
|
||||
<p class="text-xs opacity-60">Username: {$lq__person_obj.username || '--'}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -289,7 +289,7 @@
|
||||
{#each available_users as user}
|
||||
<button
|
||||
class="card p-3 variant-soft-primary hover:variant-filled-primary text-left transition-all flex flex-col gap-1"
|
||||
onclick={() => handle_link_user(user.user_id_random)}
|
||||
onclick={() => handle_link_user(user.user_id)}
|
||||
>
|
||||
<span class="font-bold flex items-center gap-2">
|
||||
<User size={14} />
|
||||
@@ -333,7 +333,7 @@
|
||||
{:else}
|
||||
<div class="space-y-2">
|
||||
{#each related_events as ev}
|
||||
<a href="/events/{ev.event_id_random}" class="card p-3 variant-soft flex flex-col gap-1 hover:variant-soft-primary transition-all">
|
||||
<a href="/events/{ev.event_id}" class="card p-3 variant-soft flex flex-col gap-1 hover:variant-soft-primary transition-all">
|
||||
<span class="font-bold text-sm">{ev.name}</span>
|
||||
<span class="text-[10px] opacity-60">{new Date(ev.start_datetime).toLocaleDateString()}</span>
|
||||
</a>
|
||||
@@ -354,7 +354,7 @@
|
||||
{:else}
|
||||
<div class="space-y-2">
|
||||
{#each related_posts as post}
|
||||
<a href="/idaa/bb/{post.post_id_random}" class="card p-3 variant-soft flex flex-col gap-1 hover:variant-soft-primary transition-all">
|
||||
<a href="/idaa/bb/{post.post_id}" class="card p-3 variant-soft flex flex-col gap-1 hover:variant-soft-primary transition-all">
|
||||
<span class="font-bold text-sm">{post.title}</span>
|
||||
<div class="flex justify-between items-center text-[10px] opacity-60">
|
||||
<span>{new Date(post.created_on).toLocaleDateString()}</span>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
let prom_api__post_comment_obj: any = $state();
|
||||
|
||||
// SVELTE 5 STABILITY: Use local state for form bindings to prevent
|
||||
// SVELTE 5 STABILITY: Use local state for form bindings to prevent
|
||||
// crashes when the global store object is briefly null.
|
||||
let post_comment_form = $state({
|
||||
content: $idaa_slct.post_comment_obj?.content ?? '',
|
||||
@@ -109,7 +109,7 @@
|
||||
// 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_random'] = parent_post_id;
|
||||
// post_comment_do['post_id'] = parent_post_id;
|
||||
}
|
||||
|
||||
log_lvl = 1;
|
||||
@@ -118,10 +118,10 @@
|
||||
}
|
||||
|
||||
if (!$idaa_slct.post_comment_id) {
|
||||
// NEW COMMENT: Ensure post_id_random is included
|
||||
// NEW COMMENT: Ensure post_id is included
|
||||
// SVELTE 5 V3 Pattern: Some child objects require the random ID suffix for parent mapping
|
||||
post_comment_do['post_id_random'] = $idaa_slct.post_id;
|
||||
|
||||
post_comment_do['post_id'] = $idaa_slct.post_id;
|
||||
|
||||
if (log_lvl) {
|
||||
console.log(
|
||||
`Current Post Comment Object List Length: ${$idaa_slct.post_comment_obj_li.length}`,
|
||||
@@ -144,7 +144,7 @@
|
||||
});
|
||||
|
||||
if (prom_api__post_comment_obj) {
|
||||
$idaa_slct.post_comment_id = prom_api__post_comment_obj.post_comment_id_random;
|
||||
$idaa_slct.post_comment_id = prom_api__post_comment_obj.post_comment_id;
|
||||
$idaa_slct.post_comment_obj = prom_api__post_comment_obj;
|
||||
|
||||
disable_submit_btn = false;
|
||||
|
||||
@@ -184,7 +184,7 @@
|
||||
if (log_lvl) {
|
||||
console.log('post_obj_create_result:', post_obj_create_result);
|
||||
}
|
||||
$idaa_slct.post_id = post_obj_create_result.post_id_random;
|
||||
$idaa_slct.post_id = post_obj_create_result.post_id;
|
||||
$idaa_slct.post_obj = post_obj_create_result;
|
||||
|
||||
return post_obj_create_result;
|
||||
@@ -570,11 +570,11 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
||||
>
|
||||
<span class="fas fa-paperclip m-1"></span>
|
||||
{linked_obj.filename}
|
||||
({linked_obj.hosted_file_id_random})
|
||||
({linked_obj.hosted_file_id})
|
||||
</a> -->
|
||||
|
||||
{#if $ae_loc.authenticated_access}
|
||||
{@const file_id = linked_obj?.hosted_file_id_random || linked_obj?.id || linked_obj?.hosted_file_id}
|
||||
{@const file_id = linked_obj?.hosted_file_id || linked_obj?.id || linked_obj?.hosted_file_id}
|
||||
{#if file_id}
|
||||
{@const ext = (linked_obj.extension || linked_obj.file_extension || ae_util.guess_file_extension(linked_obj.filename) || '').toLowerCase()}
|
||||
{#if ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'].includes(ext)}
|
||||
@@ -608,7 +608,7 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
||||
return false;
|
||||
}
|
||||
|
||||
// ae_promises[linked_obj.event_file_id_random] = handle_delete__event_file({event_file_id: linked_obj.event_file_id_random});
|
||||
// ae_promises[linked_obj.event_file_id] = handle_delete__event_file({event_file_id: linked_obj.event_file_id});
|
||||
|
||||
// First - Attempt to delete the hosted file
|
||||
ae_promises.delete__linked_obj = await core_func
|
||||
@@ -631,7 +631,7 @@ Copy and paste link: <a href="${link_base_url}?post_id=${$idaa_slct.post_id}">${
|
||||
let delete_result_li =
|
||||
$idaa_slct.post_obj.linked_li_json.filter(
|
||||
function (hosted_file_obj) {
|
||||
const current_id = hosted_file_obj?.hosted_file_id_random || hosted_file_obj?.id || hosted_file_obj?.hosted_file_id;
|
||||
const current_id = hosted_file_obj?.hosted_file_id || hosted_file_obj?.id || hosted_file_obj?.hosted_file_id;
|
||||
console.log(
|
||||
`Comparing: ${current_id} vs ${file_id}`
|
||||
);
|
||||
|
||||
@@ -248,11 +248,11 @@
|
||||
{#if ($ae_loc.trusted_access && $ae_loc.edit_mode) || $lq__post_obj?.external_person_id === $idaa_loc.novi_uuid}
|
||||
<button type="button"
|
||||
onclick={() => {
|
||||
// $idaa_slct.post_id = $idaa_slct.post_obj.post_id_random;
|
||||
// $idaa_slct.post_id = $idaa_slct.post_obj.post_id;
|
||||
$idaa_slct.post_obj = $lq__post_obj; // In case things changed
|
||||
|
||||
// const url = new URL(location);
|
||||
// url.searchParams.set('post_id', $idaa_slct.post_obj.post_id_random);
|
||||
// url.searchParams.set('post_id', $idaa_slct.post_obj.post_id);
|
||||
// history.pushState({}, '', url);
|
||||
|
||||
// $idaa_sess.bb.show_main__options = false;
|
||||
|
||||
Reference in New Issue
Block a user