fix: admin/options: wrong "nothing to save"
Massimo Melina committed
Mar 5, 2023 at 17:10 UTC
f960611064a22a1970a02137fc3e1c25a34236b1
1 file changed
+7
-4
admin/src/OptionsPage.ts
+7
-4
@@ -6,7 +6,6 @@ import { apiCall, useApi, useApiEx } from './api'
6
import { state, useSnapState } from './state'
7
import { Info, Refresh, Warning } from '@mui/icons-material'
8
import { Dict, modifiedSx, with_ } from './misc'
9
-import { subscribeKey } from 'valtio/utils'
9
import {
10
Form,
11
BoolField,
@@ -21,7 +20,7 @@ import FileField from './FileField'
20
import { alertDialog, closeDialog, confirmDialog, formDialog, newDialog, toast, waitDialog } from './dialog'
21
import { proxyWarning } from './HomePage'
22
import _ from 'lodash';
24
-import { proxy, useSnapshot } from 'valtio'
23
+import { proxy, subscribe, useSnapshot } from 'valtio'
24
25
let loaded: Dict | undefined
26
let exposedReloadStatus: undefined | (() => void)
@@ -29,7 +28,11 @@ const pageState = proxy({
28
changes: {} as Dict
29
})
30
32
-subscribeKey(state, 'config', recalculateChanges)
31
+//subscribeKey is not working (anymore) on nested changes
32
+subscribe(state, (ops) => {
33
+ if (ops.some(op => op[1][0] === 'config'))
34
+ recalculateChanges()
35
+})
36
37
export const logLabels = {
38
log: "Access log file",
@@ -38,7 +41,7 @@ export const logLabels = {
41
42
export default function OptionsPage() {
43
const { data, reload: reloadConfig, element } = useApiEx('get_config', { omit: ['vfs'] })
41
- let snap = useSnapState()
44
+ const snap = useSnapState()
45
const { changes } = useSnapshot(pageState)
46
const statusApi = useApiEx(data && 'get_status')
47
const status = statusApi.data