mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: wire up Default Tool View save in General settings
The <select> for Default Tool View was an uncontrolled dead control with no value binding, no onChange handler, and no save mechanism. This wires it up end-to-end: - Add defaultToolView to the Zustand settings store - Load the persisted value from the settings API on mount - Bind the <select> with value/onChange - Add Save Settings button mirroring SystemSection's pattern - Redirect home page to /fullscreen when defaultToolView is "fullscreen" Closes #75
This commit is contained in:
@@ -4,6 +4,7 @@ import { apiGet } from "@/lib/api";
|
||||
interface SettingsState {
|
||||
disabledTools: string[];
|
||||
experimentalEnabled: boolean;
|
||||
defaultToolView: "sidebar" | "fullscreen";
|
||||
loaded: boolean;
|
||||
fetch: () => Promise<void>;
|
||||
}
|
||||
@@ -11,6 +12,7 @@ interface SettingsState {
|
||||
export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
disabledTools: [],
|
||||
experimentalEnabled: false,
|
||||
defaultToolView: "sidebar",
|
||||
loaded: false,
|
||||
|
||||
fetch: async () => {
|
||||
@@ -23,10 +25,10 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
set({
|
||||
disabledTools: data.settings.disabledTools ? JSON.parse(data.settings.disabledTools) : [],
|
||||
experimentalEnabled: data.settings.enableExperimentalTools === "true",
|
||||
defaultToolView: data.settings.defaultToolView === "fullscreen" ? "fullscreen" : "sidebar",
|
||||
loaded: true,
|
||||
});
|
||||
} catch {
|
||||
// Settings fetch failed - default to no disabled tools
|
||||
set({ loaded: true });
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user