Fix IDAA recovery meetings auto search

This commit is contained in:
Scott Idem
2026-05-13 17:00:36 -04:00
parent cc990084fb
commit 530b53aa6d
5 changed files with 31 additions and 19 deletions

View File

@@ -31,16 +31,15 @@ if (browser) {
$idaa_slct.event_id = null;
window.parent.postMessage({ event_id: null }, '*');
// Use versioning instead of boolean to avoid loops
if ($idaa_loc.recovery_meetings.search_version === undefined) {
$idaa_loc.recovery_meetings.search_version = 0;
}
$idaa_loc.recovery_meetings.search_version++;
// Use a session-scoped trigger so the persisted IDAA profile is not rewritten
// on every page mount. Recovery Meetings only needs this to kick the initial search.
$idaa_sess.recovery_meetings.search_version++;
}
let event_id_li: Array<string> = $state([]);
let search_debounce_timer: any = null;
let last_search_id = 0;
let last_executed_key = '';
// Standardized Reactive Search Pattern (Aether UI V3)
// This effect manages the orchestration between UI state and data fetching.
@@ -56,7 +55,7 @@ $effect(() => {
// Track filters and the search version (trigger)
const qry_params = {
v: $idaa_loc.recovery_meetings.search_version,
v: $idaa_sess.recovery_meetings.search_version,
str: $idaa_loc.recovery_meetings.qry__fulltext_str,
phys: $idaa_loc.recovery_meetings.qry__physical,
virt: $idaa_loc.recovery_meetings.qry__virtual,
@@ -65,13 +64,14 @@ $effect(() => {
order: $idaa_loc.recovery_meetings.qry__order_by,
remote: $idaa_loc.recovery_meetings.qry__remote_first
};
const qry_key = JSON.stringify(qry_params);
// 2. Debounce Logic
if (search_debounce_timer) clearTimeout(search_debounce_timer);
search_debounce_timer = setTimeout(() => {
// 3. Execution (Untracked to prevent loops)
untrack(() => {
handle_search_refresh();
handle_search_refresh(qry_key);
});
}, 250);
@@ -85,7 +85,10 @@ $effect(() => {
*
* GOAL: Render matching meetings in < 50ms, then update with perfect server data.
*/
async function handle_search_refresh() {
async function handle_search_refresh(qry_key: string) {
if (qry_key === last_executed_key) return;
last_executed_key = qry_key;
const current_search_id = ++last_search_id;
const account_id = $ae_loc.account_id;
const remote_first = $idaa_loc.recovery_meetings.qry__remote_first;

View File

@@ -69,10 +69,7 @@ if (
* debounced search cycle automatically.
*/
function handle_search_trigger() {
if ($idaa_loc.recovery_meetings.search_version === undefined) {
$idaa_loc.recovery_meetings.search_version = 0;
}
$idaa_loc.recovery_meetings.search_version++;
$idaa_sess.recovery_meetings.search_version++;
}
function prevent_default<T extends Event>(fn: (event: T) => void) {