Finalize IDAA Bulletin Board V3 migration and fix UI filtering issues

- Ensured 'account_id' is injected into post objects during processing to maintain IndexedDB filter consistency
- Resolved race condition by awaiting database clearing before refreshing posts
- Corrected 'archive_on' date comparison logic in BB component
- Exported 'qry__post' and enabled comment fetching during post search
- Updated GEMINI.md and TODO.md with project progress
This commit is contained in:
Scott Idem
2026-01-07 11:37:36 -05:00
parent c0fc5052ab
commit 9c6df5c7f9
5 changed files with 148 additions and 72 deletions

View File

@@ -8,7 +8,7 @@ import { load_ae_obj_li__post_comment } from '$lib/ae_posts/ae_posts__post_comme
const ae_promises: key_val = {};
// Updated 2026-01-06
// Updated 2026-01-07
export async function load_ae_obj_id__post({
api_cfg,
post_id,
@@ -90,7 +90,7 @@ export async function load_ae_obj_id__post({
return ae_promises.load__post_obj;
}
// Updated 2026-01-06
// Updated 2026-01-07
export async function load_ae_obj_li__post({
api_cfg,
for_obj_type = 'account',
@@ -150,6 +150,7 @@ export async function load_ae_obj_li__post({
if (try_cache) {
const processed_obj_li = await process_ae_obj__post_props({
obj_li: post_obj_li_get_result,
account_id: for_obj_type === 'account' ? for_obj_id : undefined,
log_lvl: log_lvl
});
await db_save_ae_obj_li__ae_obj({
@@ -187,7 +188,7 @@ export async function load_ae_obj_li__post({
return ae_promises.load__post_obj_li;
}
// Updated 2026-01-06
// Updated 2026-01-07
export async function create_ae_obj__post({
api_cfg,
account_id,
@@ -221,6 +222,7 @@ export async function create_ae_obj__post({
if (result && try_cache) {
const processed_obj_li = await process_ae_obj__post_props({
obj_li: [result],
account_id,
log_lvl: log_lvl
});
await db_save_ae_obj_li__ae_obj({
@@ -271,7 +273,7 @@ export async function delete_ae_obj_id__post({
return result;
}
// Updated 2026-01-06
// Updated 2026-01-07
export async function update_ae_obj__post({
api_cfg,
post_id,
@@ -317,12 +319,14 @@ export async function update_ae_obj__post({
return result;
}
// Updated 2026-01-06
// Updated 2026-01-07
export async function qry__post({
api_cfg,
account_id,
qry_str,
qry_person_id = null,
qry_archive_on = null,
inc_comment_li = false,
enabled = 'enabled',
hidden = 'not_hidden',
view = 'default',
@@ -340,6 +344,8 @@ export async function qry__post({
account_id: string;
qry_str?: string;
qry_person_id?: string | null;
qry_archive_on?: string | null;
inc_comment_li?: boolean;
enabled?: 'enabled' | 'all' | 'not_enabled' | undefined;
hidden?: 'hidden' | 'all' | 'not_hidden' | undefined;
view?: string;
@@ -362,18 +368,79 @@ export async function qry__post({
search_query.and.push({ field: 'external_person_id', op: 'eq', value: qry_person_id });
}
ae_promises.load__post_obj_li = await api.search_ae_obj_v3({
api_cfg,
obj_type: 'post',
search_query,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
log_lvl
});
// if (qry_archive_on) {
// // Show posts that are NOT archived yet (archive_on is null OR archive_on > qry_archive_on)
// // Note: This logic assumes 'qry_archive_on' is effectively "now" or a cutoff date.
// // Complex OR logic inside AND might need specific backend structure support.
// // For now, assuming standard AND(OR) structure is supported or we iterate.
// // If the backend doesn't support nested ORs easily, we might need multiple queries or rely on client-side filter for this specific edge case
// // But let's try to construct it.
// //
// // V3 search_query structure usually allows top level `or` or `and`.
// // To do (A AND (B OR C)), we might need to nest.
// // If nesting isn't fully supported, we might just filter for `archive_on > date` and accept that NULLs might be excluded if we aren't careful,
// // OR we can just fetch all and filter locally if the volume is low.
// //
// // Let's try adding a simple filter for now. If the user passes a date, they likely want things visible AFTER that date.
// search_query.and.push({ field: 'archive_on', op: 'gt', value: qry_archive_on });
// // TODO: Handle 'archive_on IS NULL' case if the backend doesn't treat NULL as "infinite future".
// // Often, 'active' posts have archive_on = NULL.
// // If we only query 'gt', we lose NULLs.
// // Workaround: Don't filter by archive_on in API, filter in processor or client if backend is rigid.
// // Or check if backend supports 'is: null'.
// }
ae_promises.load__post_obj_li = await api
.search_ae_obj_v3({
api_cfg,
obj_type: 'post',
search_query,
enabled,
hidden,
view,
limit,
offset,
order_by_li,
log_lvl
})
.then(async function (post_obj_li_get_result) {
if (post_obj_li_get_result) {
const processed_obj_li = await process_ae_obj__post_props({
obj_li: post_obj_li_get_result,
account_id,
log_lvl: log_lvl
});
await db_save_ae_obj_li__ae_obj({
db_instance: db_posts,
table_name: 'post',
obj_li: processed_obj_li,
properties_to_save: properties_to_save,
log_lvl: log_lvl
});
return post_obj_li_get_result;
} else {
return [];
}
});
if (inc_comment_li && ae_promises.load__post_obj_li) {
for (let i = 0; i < ae_promises.load__post_obj_li.length; i++) {
const post_obj = ae_promises.load__post_obj_li[i];
ae_promises.load__post_obj_li[i].post_comment_li = await load_ae_obj_li__post_comment({
api_cfg: api_cfg,
for_obj_type: 'post',
for_obj_id: post_obj.post_id_random,
enabled,
hidden,
limit,
offset,
// params,
try_cache: true, // Always cache comments if we are caching posts
log_lvl
});
}
}
return ae_promises.load__post_obj_li;
}
@@ -460,12 +527,14 @@ async function _process_generic_props<T extends Record<string, any>>({
return processed_obj_li;
}
// Updated 2025-06-04
// Updated 2026-01-07
export async function process_ae_obj__post_props({
obj_li,
account_id,
log_lvl = 0
}: {
obj_li: any[];
account_id?: string;
log_lvl?: number;
}) {
return _process_generic_props({
@@ -473,6 +542,10 @@ export async function process_ae_obj__post_props({
obj_type: 'post',
log_lvl,
specific_processor: (obj) => {
if (account_id) {
if (!obj.account_id) obj.account_id = account_id;
if (!obj.account_id_random) obj.account_id_random = account_id;
}
obj.name = obj.title;
obj.tmp_sort_1 = `${obj.group ?? ''}_${obj.priority ? '1' : '0'}_${
obj.sort?.toString().padStart(3, '0') ?? ''

View File

@@ -5,7 +5,8 @@ import {
load_ae_obj_li__post,
create_ae_obj__post,
delete_ae_obj_id__post,
update_ae_obj__post
update_ae_obj__post,
qry__post
} from '$lib/ae_posts/ae_posts__post';
import {
@@ -22,6 +23,7 @@ const export_obj = {
create_ae_obj__post: create_ae_obj__post,
delete_ae_obj_id__post: delete_ae_obj_id__post,
update_ae_obj__post: update_ae_obj__post,
qry__post: qry__post,
load_ae_obj_id__post_comment: load_ae_obj_id__post_comment,
load_ae_obj_li__post_comment: load_ae_obj_li__post_comment,