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

@@ -1,16 +1,15 @@
import { AE_IDAA_LOC_VERSION } from '$lib/stores/store_versions';
import { persisted } from 'svelte-persisted-store';
import { writable } from 'svelte/store';
import type { Writable } from 'svelte/store';
import type { key_val } from '$lib/stores/ae_stores';
const ver = '2024-08-21_1646';
/* *** BEGIN *** Initialize idaa_local_data_struct */
// Persisted to localStorage. Retains Novi identity, auth state, and IDAA
// query preferences across sessions. Wiped on schema change via store_versions.ts.
const idaa_local_data_struct: key_val = {
ver: ver,
__version: AE_IDAA_LOC_VERSION,
name: 'Aether - IDAA',
title: `OSIT's Æ IDAA`,
@@ -111,7 +110,6 @@ export const idaa_loc: Writable<key_val> = persisted(
/* *** BEGIN *** Initialize idaa_session_data_struct */
// In-memory only (not persisted). Resets on page load.
const idaa_session_data_struct: key_val = {
ver: ver,
log_lvl: 1,
archives: {
@@ -137,6 +135,7 @@ const idaa_session_data_struct: key_val = {
recovery_meetings: {
qry__status: null,
qry__fulltext_str: null,
search_version: 0,
edit__event_obj: null,
@@ -185,7 +184,7 @@ const idaa_trig_template: key_val = {
event_id: false,
post_id: false
};
export const idaa_trig: any = writable(idaa_trig_template);
export const idaa_trig: Writable<key_val> = writable(idaa_trig_template);
// Promise map — keyed by object type; used to track in-flight async operations.
const idaa_prom_template: key_val = {
@@ -194,4 +193,4 @@ const idaa_prom_template: key_val = {
event_id: false,
post_id: false
};
export const idaa_prom: any = writable(idaa_prom_template);
export const idaa_prom: Writable<key_val> = writable(idaa_prom_template);

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) {