|
1 | 1 | import { useState } from 'react'; |
2 | 2 | import { useAppContext } from '../utils/app.context'; |
3 | | -import { CONFIG_INFO } from '../utils/initConfig'; |
4 | | -import { isDev } from '../utils/initConfig'; |
| 3 | +import { CONFIG_INFO, getServerDefaultConfig, isDev } from '../utils/initConfig'; |
5 | 4 | import StorageUtils from '../utils/storage'; |
6 | 5 | import { classNames, isBoolean, isNumeric, isString } from '../utils/misc'; |
7 | 6 | import { |
@@ -272,9 +271,17 @@ export default function SettingDialog({ |
272 | 271 | // clone the config object to prevent direct mutation |
273 | 272 | const [localConfig, setLocalConfig] = useState<AppConfig>({ ...config }); |
274 | 273 |
|
275 | | - const resetConfig = () => { |
276 | | - if (window.confirm('Are you sure you want to reset all settings?')) { |
277 | | - setLocalConfig({ ...config }); |
| 274 | + const resetConfig = async () => { |
| 275 | + if (!window.confirm('Reset all settings from server defaults?')) return; |
| 276 | + |
| 277 | + try { |
| 278 | + const cfg = await getServerDefaultConfig(config.apiKey); |
| 279 | + StorageUtils.setConfig(cfg); |
| 280 | + setLocalConfig({ ...cfg }); |
| 281 | + console.info('[Config] Reset from server config'); |
| 282 | + } catch (err) { |
| 283 | + console.error('[Config] Failed to fetch server defaults:', err); |
| 284 | + alert('Failed to fetch server default config.'); |
278 | 285 | } |
279 | 286 | }; |
280 | 287 |
|
|
0 commit comments