import { h, Fragment } from 'preact'; import BaseAppBar from './components/AppBar'; import LinkedLogo from './components/LinkedLogo'; import Menu, { MenuItem, MenuSeparator } from './components/Menu'; import AutoAwesomeIcon from './icons/AutoAwesome'; import LightModeIcon from './icons/LightMode'; import DarkModeIcon from './icons/DarkMode'; import FrigateRestartIcon from './icons/FrigateRestart'; import Dialog from './components/Dialog'; import { useDarkMode } from './context'; import { useCallback, useRef, useState } from 'preact/hooks'; import { useRestart } from './api/mqtt'; export default function AppBar() { const [showMoreMenu, setShowMoreMenu] = useState(false); const [showDialog, setShowDialog] = useState(false); const [showDialogWait, setShowDialogWait] = useState(false); const { setDarkMode } = useDarkMode(); const { send: sendRestart } = useRestart(); const handleSelectDarkMode = useCallback( (value, label) => { setDarkMode(value); setShowMoreMenu(false); }, [setDarkMode, setShowMoreMenu] ); const moreRef = useRef(null); const handleShowMenu = useCallback(() => { setShowMoreMenu(true); }, [setShowMoreMenu]); const handleDismissMoreMenu = useCallback(() => { setShowMoreMenu(false); }, [setShowMoreMenu]); const handleClickRestartDialog = useCallback(() => { setShowDialog(false); setShowDialogWait(true); sendRestart(); }, [setShowDialog]); const handleDismissRestartDialog = () => { setShowDialog(false); }; const handleRestart = useCallback(() => { setShowMoreMenu(false); setShowDialog(true); }, [setShowDialog]); return ( {showMoreMenu ? ( ) : null}, {showDialog ? ( ) : null}, {showDialogWait ? ( ) : null} ); }