Update notification-settings.tsx

This commit is contained in:
MacRimi
2026-03-21 20:41:02 +01:00
parent ff08f4c0b5
commit 6534fa7171
+24 -15
View File
@@ -368,6 +368,13 @@ export function NotificationSettings() {
if (showHistory) loadHistory() if (showHistory) loadHistory()
}, [showHistory, loadHistory]) }, [showHistory, loadHistory])
// Auto-expand AI section when AI is enabled
useEffect(() => {
if (config.ai_enabled) {
setShowAdvanced(true)
}
}, [config.ai_enabled])
const updateConfig = (updater: (prev: NotificationConfig) => NotificationConfig) => { const updateConfig = (updater: (prev: NotificationConfig) => NotificationConfig) => {
setConfig(prev => { setConfig(prev => {
const next = updater(prev) const next = updater(prev)
@@ -529,21 +536,23 @@ export function NotificationSettings() {
/** Flatten the nested NotificationConfig into the flat key-value map the backend expects. */ /** Flatten the nested NotificationConfig into the flat key-value map the backend expects. */
const flattenConfig = (cfg: NotificationConfig): Record<string, string> => { const flattenConfig = (cfg: NotificationConfig): Record<string, string> => {
const flat: Record<string, string> = { const flat: Record<string, string> = {
enabled: String(cfg.enabled), enabled: String(cfg.enabled),
ai_enabled: String(cfg.ai_enabled), ai_enabled: String(cfg.ai_enabled),
ai_provider: cfg.ai_provider, ai_provider: cfg.ai_provider,
ai_model: cfg.ai_model, ai_model: cfg.ai_model,
ai_language: cfg.ai_language, ai_language: cfg.ai_language,
ai_ollama_url: cfg.ai_ollama_url, ai_ollama_url: cfg.ai_ollama_url,
ai_openai_base_url: cfg.ai_openai_base_url, ai_openai_base_url: cfg.ai_openai_base_url,
hostname: cfg.hostname, ai_prompt_mode: cfg.ai_prompt_mode || "default",
webhook_secret: cfg.webhook_secret, ai_custom_prompt: cfg.ai_custom_prompt || "",
webhook_allowed_ips: cfg.webhook_allowed_ips, hostname: cfg.hostname,
pbs_host: cfg.pbs_host, webhook_secret: cfg.webhook_secret,
pve_host: cfg.pve_host, webhook_allowed_ips: cfg.webhook_allowed_ips,
pbs_trusted_sources: cfg.pbs_trusted_sources, pbs_host: cfg.pbs_host,
} pve_host: cfg.pve_host,
pbs_trusted_sources: cfg.pbs_trusted_sources,
}
// Flatten per-provider API keys // Flatten per-provider API keys
if (cfg.ai_api_keys) { if (cfg.ai_api_keys) {
for (const [provider, key] of Object.entries(cfg.ai_api_keys)) { for (const [provider, key] of Object.entries(cfg.ai_api_keys)) {