diff --git a/web/src/AppBar.jsx b/web/src/AppBar.jsx index c6da404e2..f2d0a22f5 100644 --- a/web/src/AppBar.jsx +++ b/web/src/AppBar.jsx @@ -12,7 +12,7 @@ import { useCallback, useRef, useState } from 'preact/hooks'; export default function AppBar() { const [showMoreMenu, setShowMoreMenu] = useState(false); - const [showDialogRestart, setShowDialogRestart] = useState(false); + const [showDialogRestart, setShowDialogRestart] = useState(0); const { setDarkMode } = useDarkMode(); const handleSelectDarkMode = useCallback( diff --git a/web/src/components/DialogRestart.jsx b/web/src/components/DialogRestart.jsx index d8519b628..d066275ce 100644 --- a/web/src/components/DialogRestart.jsx +++ b/web/src/components/DialogRestart.jsx @@ -4,6 +4,7 @@ import { useCallback, useEffect, useState } from 'preact/hooks'; import { useRestart } from '../api/mqtt'; export default function DialogRestart({ show, setShow }) { + const { payload: restartedMessage = null, send: sendRestart } = useRestart(); useEffect(() => { if (show === 2) { @@ -11,12 +12,12 @@ export default function DialogRestart({ show, setShow }) { setTimeout(async () => { const delay = (ms) => new Promise(res => setTimeout(res, ms)); - while (show === 2) { + /* eslint-disable no-constant-condition */ + while (true) { try { const response = await fetch('/api/config', { method: 'GET' }); if (await response.status === 200) { - setShow(0); - continue; + break;; } } catch (e) {}