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