feat(launcher): implement device heartbeat and background sync engine

- Hardened 'find_object_id' in Dexie to support 'event_' prefixed IDs.
- Implemented singleton 'LauncherBackgroundSync' in root launcher layout.
- Added V3-compliant heartbeat and room refresh cycles.
- Fixed redundant component imports and Skeleton UI prop errors.
- Added 'inc_file_li' support to event API loader.
This commit is contained in:
Scott Idem
2026-01-26 11:23:12 -05:00
parent 54a2cfa59f
commit 79917edffc
9 changed files with 61 additions and 27 deletions

View File

@@ -13,7 +13,14 @@ function find_object_id(
table_name: string,
log_lvl: number
): string | number | undefined {
const potential_keys = ['id', 'id_random', `${table_name}_id`, `${table_name}_id_random`];
const potential_keys = [
'id',
'id_random',
`${table_name}_id`,
`${table_name}_id_random`,
`event_${table_name}_id`,
`event_${table_name}_id_random`
];
for (const key of potential_keys) {
if (obj[key]) {
@@ -27,10 +34,12 @@ function find_object_id(
}
}
console.error(
`Object is missing a valid ID for table "${table_name}". It will be skipped.`,
obj
);
if (log_lvl) {
console.error(
`Object is missing a valid ID for table "${table_name}". It will be skipped. Checked keys: ${potential_keys.join(', ')}`,
obj
);
}
return undefined;
}

View File

@@ -20,6 +20,7 @@ export async function load_ae_obj_id__event({
event_id,
view = 'default',
inc_device_li = false,
inc_file_li = false,
inc_location_li = false,
inc_session_li = false,
inc_template_li = false,
@@ -30,6 +31,7 @@ export async function load_ae_obj_id__event({
event_id: string;
view?: string;
inc_device_li?: boolean;
inc_file_li?: boolean;
inc_location_li?: boolean;
inc_session_li?: boolean;
inc_template_li?: boolean;
@@ -45,7 +47,7 @@ export async function load_ae_obj_id__event({
if (log_lvl) console.log('Browser is offline. Skipping API and attempting cache load.');
ae_promises.load__event_obj = await db_events.event.get(event_id);
if (ae_promises.load__event_obj) {
return await _handle_nested_loads(ae_promises.load__event_obj, { api_cfg, inc_device_li, inc_location_li, inc_session_li, inc_template_li, log_lvl });
return await _handle_nested_loads(ae_promises.load__event_obj, { api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl });
}
return null;
}
@@ -97,13 +99,13 @@ export async function load_ae_obj_id__event({
return null;
}
return await _handle_nested_loads(ae_promises.load__event_obj, { api_cfg, inc_device_li, inc_location_li, inc_session_li, inc_template_li, log_lvl });
return await _handle_nested_loads(ae_promises.load__event_obj, { api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl });
}
/**
* Shared logic for loading nested child collections
*/
async function _handle_nested_loads(event_obj: any, { api_cfg, inc_device_li, inc_location_li, inc_session_li, inc_template_li, log_lvl }: any) {
async function _handle_nested_loads(event_obj: any, { api_cfg, inc_device_li, inc_file_li, inc_location_li, inc_session_li, inc_template_li, log_lvl }: any) {
const current_event_id = event_obj.event_id_random || event_obj.event_id || event_obj.id;
if (inc_device_li) {
@@ -114,6 +116,16 @@ async function _handle_nested_loads(event_obj: any, { api_cfg, inc_device_li, in
log_lvl
});
}
if (inc_file_li) {
event_obj.event_file_li = await load_ae_obj_li__event_file({
api_cfg,
for_obj_type: 'event',
for_obj_id: current_event_id,
enabled: 'all',
limit: 100,
log_lvl
});
}
if (inc_location_li) {
event_obj.event_location_obj_li = await load_ae_obj_li__event_location({
api_cfg,

View File

@@ -5,6 +5,7 @@ import { db_save_ae_obj_li__ae_obj } from '$lib/ae_core/core__idb_dexie';
import { db_events } from '$lib/ae_events/db_events';
import type { ae_EventLocation } from '$lib/types/ae_types';
import { load_ae_obj_li__event_file } from '$lib/ae_events/ae_events__event_file';
import { load_ae_obj_li__event_session } from '$lib/ae_events/ae_events__event_session';
const ae_promises: key_val = {};

View File

@@ -43,7 +43,7 @@
class: classes = ''
}: Props = $props();
let editor_element: HTMLDivElement = $state();
let editor_element: HTMLDivElement | undefined = $state();
// let editorView: any = $state(); // Removed redundant declaration
let cm_modules: any = $state(); // To hold the dynamically loaded CodeMirror modules
let editor_extensions: any[] = $state([]);

View File

@@ -10,7 +10,7 @@
let { content = $bindable(''), placeholder = 'Start typing...' }: Props = $props();
let editor_container: HTMLDivElement = $state();
let editor_container: HTMLDivElement | undefined = $state();
let editor_view: any;
let cm: any; // Declare cm at the top level