API key auth only provides short-lived session tokens (8hrs or until session restart) with no refresh mechanism, unlike OAuth which persists via .credentials.json. Remove the non-functional API key settings UI and all supporting code (frontend state, Tauri commands, keyring storage, container env var injection, and fingerprint-based recreation checks) to avoid user confusion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
1021 B
TypeScript
41 lines
1021 B
TypeScript
import { useCallback } from "react";
|
|
import { useShallow } from "zustand/react/shallow";
|
|
import { useAppState } from "../store/appState";
|
|
import * as commands from "../lib/tauri-commands";
|
|
import type { AppSettings } from "../lib/types";
|
|
|
|
export function useSettings() {
|
|
const { appSettings, setAppSettings } = useAppState(
|
|
useShallow(s => ({
|
|
appSettings: s.appSettings,
|
|
setAppSettings: s.setAppSettings,
|
|
}))
|
|
);
|
|
|
|
const loadSettings = useCallback(async () => {
|
|
try {
|
|
const settings = await commands.getSettings();
|
|
setAppSettings(settings);
|
|
return settings;
|
|
} catch (e) {
|
|
console.error("Failed to load settings:", e);
|
|
return null;
|
|
}
|
|
}, [setAppSettings]);
|
|
|
|
const saveSettings = useCallback(
|
|
async (settings: AppSettings) => {
|
|
const updated = await commands.updateSettings(settings);
|
|
setAppSettings(updated);
|
|
return updated;
|
|
},
|
|
[setAppSettings],
|
|
);
|
|
|
|
return {
|
|
appSettings,
|
|
loadSettings,
|
|
saveSettings,
|
|
};
|
|
}
|