fix(types): add file_display_overrides + launch_profiles to LauncherLocState
Both fields were being written to launcher_loc.current dynamically and
read back via 'as Record<string, unknown>' casts because they were absent
from the LauncherLocState interface and launcher_loc_defaults.
file_display_overrides: Record<string, 'extend' | 'mirror' | 'none'>
— per-device display override map keyed by event_file_id.
— local-only workaround until event_file.cfg_json is added on backend.
— TODO comment preserved; migrate once the backend column exists.
launch_profiles: Record<string, Partial<LaunchProfile>> | null
— local per-device launch profile overrides (device API config takes
priority; these override the built-in DEFAULT_LAUNCH_PROFILES).
Defaults added to launcher_loc_defaults ({} and null respectively).
All 3 type casts in launcher_file_cont.svelte removed.
This commit is contained in:
@@ -95,10 +95,9 @@ let open_file_error_detail: string | null = $state(null);
|
||||
|
||||
let open_in_os_loading: boolean = $state(false);
|
||||
|
||||
/** Reactive display override for this file — stored in $events_loc (localStorage) not in the backend. */
|
||||
/** Reactive display override for this file — stored locally (per-device) because event_file has no cfg_json column yet. */
|
||||
const current_display_override = $derived.by(() => {
|
||||
const overrides = ((launcher_loc.current as Record<string, unknown>)?.file_display_overrides ?? {}) as Record<string, string>;
|
||||
return (overrides[event_file_id] ?? null) as 'extend' | 'mirror' | 'none' | null;
|
||||
return (launcher_loc.current.file_display_overrides[event_file_id] ?? null) as 'extend' | 'mirror' | 'none' | null;
|
||||
});
|
||||
|
||||
/** State for the native test mode debug popup */
|
||||
@@ -143,11 +142,9 @@ function get_launch_profile(
|
||||
native_device?.launch_profiles ??
|
||||
null;
|
||||
const local_profiles = launcher_loc.current?.launch_profiles ?? null;
|
||||
// Display override is stored per-device in $events_loc — not in the backend (event_file has no JSON column).
|
||||
// Display override is stored per-device in launcher_loc — not in the backend (event_file has no cfg_json column yet).
|
||||
// This is intentional: display mode is a room/device preference, not a global file property.
|
||||
const launcher_kv = launcher_loc.current as Record<string, unknown>;
|
||||
const file_display_overrides = (launcher_kv?.file_display_overrides ?? {}) as Record<string, string>;
|
||||
const display_override = (file_display_overrides[event_file_id] ?? null) as 'extend' | 'mirror' | 'none' | null;
|
||||
const display_override = (launcher_loc.current.file_display_overrides[event_file_id] ?? null) as 'extend' | 'mirror' | 'none' | null;
|
||||
|
||||
// open_in_os = 'win' routes to the Windows-variant profile for apps that have one.
|
||||
// These profiles target Windows PowerPoint / LibreOffice / Acrobat running via Parallels or CrossOver.
|
||||
@@ -749,14 +746,13 @@ function prevent_default<T extends Event>(fn: (event: T) => void) {
|
||||
onclick={() => {
|
||||
const cur = current_display_override;
|
||||
const next: 'extend' | 'mirror' | null = !cur ? 'extend' : cur === 'extend' ? 'mirror' : null;
|
||||
const launcher = launcher_loc.current as Record<string, unknown>;
|
||||
const new_overrides = { ...((launcher?.file_display_overrides ?? {}) as Record<string, string>) };
|
||||
const new_overrides = { ...launcher_loc.current.file_display_overrides };
|
||||
if (next === null) {
|
||||
delete new_overrides[event_file_id];
|
||||
} else {
|
||||
new_overrides[event_file_id] = next;
|
||||
}
|
||||
launcher.file_display_overrides = new_overrides;
|
||||
launcher_loc.current.file_display_overrides = new_overrides;
|
||||
}}
|
||||
class="btn btn-sm transition-all"
|
||||
class:preset-tonal-primary={current_display_override === 'extend'}
|
||||
|
||||
Reference in New Issue
Block a user