admin/internet: avoid useless api call
Massimo Melina committed
Sep 29, 2023 at 20:18 UTC
84f5b15d81e60ba7e771e009181b92658e1e7545
1 file changed
+5
-2
admin/src/InternetPage.ts
+5
-2
@@ -44,7 +44,6 @@ export default function InternetPage() {
44
const [values, setValues] = useState<any>()
45
const cert = useApiEx('get_cert')
46
useEffect(() => { apiCall('get_config', { only: ['acme_domain', 'acme_email', 'acme_renew'] }).then(setValues) } , [])
47
- useApiEx('set_config', { values })
47
if (!status || !values) return h(CircularProgress)
48
return element || status.element || h(Card, {}, h(CardContent, {},
49
h(Flex, { gap: '.5em', fontSize: 'x-large', mb: 1, alignItems: 'center' }, "HTTPS",
@@ -63,7 +62,11 @@ export default function InternetPage() {
62
gridProps: {rowSpacing:1},
63
values,
64
set(v, k) {
66
- setValues((was: any) => ({ ...was, [k]: v }))
65
+ setValues((was: any) => {
66
+ const values = { ...was, [k]: v }
67
+ apiCall('set_config', { values })
68
+ return values
69
+ })
70
},
71
fields: [
72
md("Generate certificate using [Let's Encrypt](https://letsencrypt.org)"),