fix(webui): sync file edit display preference
This commit is contained in:
@@ -11,6 +11,7 @@ export interface LocalPreferences {
|
||||
}
|
||||
|
||||
export const LOCAL_PREFS_STORAGE_KEY = "nanobot-webui.settings-preferences";
|
||||
export const LOCAL_PREFS_CHANGED_EVENT = "nanobot-webui.local-preferences-changed";
|
||||
|
||||
export const DEFAULT_LOCAL_PREFS: LocalPreferences = {
|
||||
density: "comfortable",
|
||||
@@ -40,3 +41,15 @@ export function readLocalPreferences(): LocalPreferences {
|
||||
return DEFAULT_LOCAL_PREFS;
|
||||
}
|
||||
}
|
||||
|
||||
export function writeLocalPreferences(preferences: LocalPreferences): void {
|
||||
try {
|
||||
window.localStorage.setItem(LOCAL_PREFS_STORAGE_KEY, JSON.stringify(preferences));
|
||||
} catch {
|
||||
// Browser-only preferences should never block settings.
|
||||
}
|
||||
window.dispatchEvent(new CustomEvent<LocalPreferences>(
|
||||
LOCAL_PREFS_CHANGED_EVENT,
|
||||
{ detail: preferences },
|
||||
));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user