refactor: implement frontend safety net for missing event file foreign keys

- Updated '_refresh_file_li_background' to manually inject 'for_id', 'for_type', and specific object IDs if they are missing from the API response.
- This ensures robust indexing and retrieval from Dexie even when the V3 backend fails to populate linking fields.
- Verified that these 'fixed' objects are correctly processed and saved to the local cache.
This commit is contained in:
Scott Idem
2026-02-06 16:55:00 -05:00
parent 7b61145a66
commit 4eabc7eeba

View File

@@ -193,8 +193,22 @@ async function _refresh_file_li_background({
log_lvl
});
if (result_li) {
// SAFETY NET: If API returns null IDs, inject the ones we used for the query
const fixed_li = result_li.map((obj: any) => {
const fixed_obj = { ...obj };
if (!fixed_obj.for_type) fixed_obj.for_type = for_obj_type;
if (!fixed_obj.for_id) fixed_obj.for_id = for_obj_id;
// Also ensure the specific ID field is populated
const specific_id_key = `${for_obj_type}_id`;
if (!fixed_obj[specific_id_key])
fixed_obj[specific_id_key] = for_obj_id;
return fixed_obj;
});
const processed = await process_ae_obj__event_file_props({
obj_li: result_li,
obj_li: fixed_li,
log_lvl
});
if (try_cache) {