[Perf] Fix liveQuery reactivity, silence debug logs, add performance guidelines
- launcher/+layout.svelte: convert lq__event_session_obj from $derived to $derived.by() so Svelte tracks event_session_id as a dependency; the old pattern read the store inside the Dexie async callback where Svelte's tracking is off, so the liveQuery never updated on session change - ae_events__event_file.ts: fix hardcoded log_lvl: 2 in SWR fire-and-forget background refresh (always-on debug logging on every cache hit) → 0 - e_app_sign_in_out.svelte: lower 6 call-site log levels (1×log_lvl:2, 5×log_lvl:1) to 0; sign-in runs on every page load - element_manage_hosted_file_li.svelte: log_lvl:2 → 0 in refresh call; remove log_lvl=1 assignment + debug block inside click handler; log_lvl:1 → 0 in delete call - AE__Performance_Guidelines.md: add 5 Svelte 5 runes rules covering $derived.by() for reactive liveQuery, liveQuery purity, cheap equality guards ($id+updated_on, ID-join, shallow_equal), untrack() requirement, and log_lvl discipline Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -151,7 +151,7 @@ export async function load_ae_obj_li__event_file({
|
||||
offset,
|
||||
order_by_li,
|
||||
try_cache,
|
||||
log_lvl: 2
|
||||
log_lvl: 0
|
||||
});
|
||||
return cached_li;
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@
|
||||
account_id: $slct.account_id,
|
||||
user_id: user_id,
|
||||
base_url: $ae_loc.base_url,
|
||||
log_lvl: 2
|
||||
log_lvl: 0
|
||||
});
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
account_id: $slct.account_id,
|
||||
null_account_id: false,
|
||||
email: email,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
})
|
||||
.then((user_response) => {
|
||||
if (user_response?.user_id_random) {
|
||||
@@ -291,7 +291,7 @@
|
||||
account_id: $slct.account_id,
|
||||
null_account_id: false,
|
||||
email: user_email,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
if (!ae_promises.load__user_obj_li) {
|
||||
@@ -465,7 +465,7 @@
|
||||
// null_account_id: false, // Set to true to allow to authenticate as global user (Super or Manager)
|
||||
user_id: $ae_sess.auth__entered_user_id,
|
||||
user_auth_key: $ae_sess.auth__entered_user_key,
|
||||
log_lvl: 2
|
||||
log_lvl: 0
|
||||
})
|
||||
.then((user_response) => {
|
||||
// console.log(`HERE:`, user_response);
|
||||
@@ -520,7 +520,7 @@
|
||||
hidden: 'all',
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
})
|
||||
.then((person_response) => {
|
||||
// Safety Check: Ensure the response is valid and contains at least one record before accessing index 0.
|
||||
@@ -562,7 +562,7 @@
|
||||
// null_account_id: false, // Set to true to allow to authenticate as global user (Super or Manager)
|
||||
username: $ae_sess.auth__entered_username,
|
||||
password: $ae_sess.auth__entered_password,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
})
|
||||
.then((user_response) => {
|
||||
if (user_response?.user_id) {
|
||||
@@ -616,7 +616,7 @@
|
||||
hidden: 'all',
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
})
|
||||
.then((person_response) => {
|
||||
// Safety Check: Ensure the response is valid and contains at least one record before accessing index 0.
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
limit: 250,
|
||||
// params: params,
|
||||
try_cache: true,
|
||||
log_lvl: 2
|
||||
log_lvl: 0
|
||||
});
|
||||
|
||||
// ae_tmp.show__file_li = false;
|
||||
@@ -158,10 +158,6 @@
|
||||
slct_hosted_file_id = hosted_file_obj.hosted_file_id;
|
||||
slct_hosted_file_obj = hosted_file_obj;
|
||||
}
|
||||
log_lvl = 1;
|
||||
if (log_lvl) {
|
||||
console.log(`slct_hosted_file_kv:`, slct_hosted_file_kv);
|
||||
}
|
||||
}}
|
||||
class="btn btn-sm preset-tonal-secondary hover:preset-filled-secondary-500"
|
||||
title="Add/Remove file to/from the locally stored uploaded file list. This is referenced by other AE components."
|
||||
@@ -195,7 +191,7 @@
|
||||
link_to_id: link_to_id,
|
||||
rm_orphan: true,
|
||||
fake_delete: false,
|
||||
log_lvl: 1
|
||||
log_lvl: 0
|
||||
});
|
||||
}}
|
||||
class:hidden={!$ae_loc.administrator_access}
|
||||
|
||||
@@ -222,9 +222,12 @@
|
||||
});
|
||||
|
||||
// Event Session (Main View Trigger - Needed for Global Header/Idle)
|
||||
let lq__event_session_obj = $derived(
|
||||
liveQuery(() => db_events.session.get($events_slct.event_session_id))
|
||||
);
|
||||
// $derived.by: capture ID in outer closure so Svelte tracks it as a dependency.
|
||||
// liveQuery callback runs in Dexie's async context where Svelte tracking is off.
|
||||
let lq__event_session_obj = $derived.by(() => {
|
||||
const id = $events_slct.event_session_id;
|
||||
return liveQuery(() => db_events.session.get(id));
|
||||
});
|
||||
|
||||
// Store sync effects — keep liveQuery closures pure (data-only) and sync to
|
||||
// $events_slct here in reactive effects instead. Comparing updated_on + id is
|
||||
|
||||
Reference in New Issue
Block a user