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

@@ -54,33 +54,19 @@
}
// *** Functions and Logic
// WARNING: For now the archive_on is hardcoded. It should be configurable.
let lq__post_obj_li = $derived(
liveQuery(async () => {
let results = await db_posts.post
.where('account_id')
.equals($slct.account_id)
// .and((x) => (x.archive_on === null || x.archive_on > (new Date()).toISOString()))
.and((x) => x.archive_on === null || x.archive_on > new Date().toISOString()) // null or future posts only
// .and((x) => (x.archive_on < (new Date()).toISOString())) // past posts only
// .and((x) => (x.archive_on > (new Date()).toISOString())) // future posts only
// .orderBy('updated_on')
// .toArray()
.reverse()
.limit($idaa_loc.bb.qry__limit)
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
// .sortBy('updated_on, created_on');
// .sortBy('[updated_on+created_on]');
// .sortBy('[created_on+updated_on]');
return results;
})
);
// Updated 2026-01-07
let lq__post_obj_li = $derived(liveQuery(async () => {
const now = new Date();
const results = await db_posts.post
.where('account_id').equals($slct.account_id ?? '')
.filter((x) => x.archive_on === null || new Date(x.archive_on) > now)
.toArray();
return results;
}));
// let lq__post_obj = $derived(liveQuery(async () => {
// let results = await db_posts.post
// .get($idaa_slct.post_id ?? ''); // null or undefined does not reset things like '' does
// .get($slct.post_id ?? ''); // null or undefined does not reset things like '' does
// return results;
// }));
@@ -88,7 +74,7 @@
// let lq__post_comment_obj_li = $derived(liveQuery(async () => {
// let results = await db_posts.comment
// .where('post_id')
// .equals($idaa_slct.post_id ?? '') // null or undefined does not reset things like '' does
// .equals($slct.post_id ?? '') // null or undefined does not reset things like '' does
// .reverse()
// .sortBy('updated_on');
// // .sortBy('title');
@@ -98,7 +84,7 @@
// 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
// .get($slct.post_comment_id ?? ''); // null or undefined does not reset things like '' does
// return results;
// }));
@@ -112,34 +98,38 @@
console.log(`Triggered: $idaa_trig.post_li`);
}
// This may need to be rethought... For now things are cleared if query is anything but 'all' for enabled and hidden.
if (
$idaa_loc.bb.qry__enabled !== 'all' ||
$idaa_loc.bb.qry__hidden !== 'all' ||
$idaa_loc.bb.qry__limit < 50
) {
console.log(`Deleting disabled or hidden post.`);
let results = db_posts.post.clear();
console.log(`Deleted ${results} disabled post.`);
// Wrap the data fetching logic in an async function to await clearing
const refresh_posts = async () => {
// This may need to be rethought... For now things are cleared if query is anything but 'all' for enabled and hidden.
if (
$idaa_loc.bb.qry__enabled !== 'all' ||
$idaa_loc.bb.qry__hidden !== 'all' ||
$idaa_loc.bb.qry__limit < 50
) {
console.log(`Deleting disabled or hidden post.`);
await db_posts.post.clear();
console.log(`Deleted disabled post.`);
console.log(`Deleting disabled or hidden post comments.`);
results = db_posts.comment.clear();
console.log(`Deleted ${results} disabled post comments.`);
}
console.log(`Deleting disabled or hidden post comments.`);
await db_posts.comment.clear();
console.log(`Deleted disabled post comments.`);
}
$idaa_prom.load__post_obj_li = posts_func.load_ae_obj_li__post({
api_cfg: $ae_api,
for_obj_type: 'account',
for_obj_id: $idaa_slct.account_id,
qry_archive_on: '2024-01-01', // (new Date()).toISOString(),
inc_comment_li: true,
enabled: $idaa_loc.bb.qry__enabled,
hidden: $idaa_loc.bb.qry__hidden,
limit: $idaa_loc.bb.qry__limit,
order_by_li: $idaa_loc.bb.qry__order_by_li,
// try_cache: true,
log_lvl: log_lvl
});
$idaa_prom.load__post_obj_li = posts_func.qry__post({
api_cfg: $ae_api,
account_id: $slct.account_id,
qry_archive_on: '2024-01-01', // (new Date()).toISOString(),
inc_comment_li: true,
enabled: $idaa_loc.bb.qry__enabled,
hidden: $idaa_loc.bb.qry__hidden,
limit: $idaa_loc.bb.qry__limit,
order_by_li: $idaa_loc.bb.qry__order_by_li,
// try_cache: true,
log_lvl: log_lvl
});
};
refresh_posts();
}
});