improved user experience

This commit is contained in:
ElMoribond 2021-07-13 10:37:32 +02:00 committed by GitHub
parent 3f1a67a03c
commit 4b538d54b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,9 @@
import { h, Fragment } from 'preact'; import { h, Fragment } from 'preact';
import { useCallback, useEffect, useState } from 'preact/hooks'; import { useCallback, useEffect, useState } from 'preact/hooks';
import Dialog from './Dialog'; import Dialog from './Dialog';
import { useApiHost } from '../api';
import { useRestart } from '../api/mqtt'; import { useRestart } from '../api/mqtt';
export default function DialogRestart({ show, setShow }) { export default function DialogRestart({ show, setShow }) {
const apiHost = useApiHost();
const { payload: detectRestarted = null, send: sendRestart } = useRestart(); const { payload: detectRestarted = null, send: sendRestart } = useRestart();
const [dialogTitle, setDialogTitle] = useState('Restart in progress'); const [dialogTitle, setDialogTitle] = useState('Restart in progress');
@ -22,8 +20,8 @@ export default function DialogRestart({ show, setShow }) {
await delay(3456); await delay(3456);
while (true) { while (true) {
try { try {
const response = await fetch(`${apiHost}/api/config`, { method: 'GET' }); const response = await fetch('/api/config', { method: 'GET' });
if (await response.status == 200) if (await response.status === 200)
window.location.reload(); window.location.reload();
} }
catch (e) {} catch (e) {}