import { useRef, useState } from "preact/hooks"; import { t } from "../../services/i18n"; import Button from "../react/Button"; import FormTextBox from "../react/FormTextBox"; import Modal from "../react/Modal"; import protected_session from "../../services/protected_session"; import { useTriliumEvent } from "../react/hooks"; export default function ProtectedSessionPasswordDialog() { const [ shown, setShown ] = useState(false); const [ password, setPassword ] = useState(""); const inputRef = useRef(null); useTriliumEvent("showProtectedSessionPasswordDialog", () => setShown(true)); useTriliumEvent("closeProtectedSessionPasswordDialog", () => setShown(false)); return ( } onSubmit={() => protected_session.setupProtectedSession(password)} onShown={() => inputRef.current?.focus()} onHidden={() => setShown(false)} show={shown} > ) }