fix(webui): sync file edit display preference
This commit is contained in:
1 parent
7768672c5b
commit
6851a6ebd4
4 files changed
+69
-7
No files matched your search
@@ -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