mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: unlock view should use base theme scope
This commit is contained in:
@@ -202,15 +202,13 @@ function DesktopAppContents({
|
||||
bg: "background"
|
||||
}}
|
||||
>
|
||||
<ScopedThemeProvider scope="editor" sx={{ flex: 1 }}>
|
||||
{isAppLoaded && (
|
||||
<SuspenseLoader
|
||||
fallback={<EditorLoader />}
|
||||
component={HashRouter}
|
||||
condition={isAppLoaded}
|
||||
/>
|
||||
)}
|
||||
</ScopedThemeProvider>
|
||||
{isAppLoaded && (
|
||||
<SuspenseLoader
|
||||
fallback={<EditorLoader />}
|
||||
component={HashRouter}
|
||||
condition={isAppLoaded}
|
||||
/>
|
||||
)}
|
||||
</Flex>
|
||||
</Allotment.Pane>
|
||||
</Allotment>
|
||||
|
||||
@@ -27,17 +27,20 @@ import Field from "../field";
|
||||
import { showToast } from "../../utils/toast";
|
||||
import { ErrorText } from "../error-text";
|
||||
|
||||
function Unlock(props) {
|
||||
type UnlockProps = {
|
||||
noteId: string;
|
||||
};
|
||||
function Unlock(props: UnlockProps) {
|
||||
const { noteId } = props;
|
||||
|
||||
const [isWrong, setIsWrong] = useState(false);
|
||||
const [isUnlocking, setIsUnlocking] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
const passwordRef = useRef();
|
||||
const passwordRef = useRef<HTMLInputElement>();
|
||||
|
||||
const note = useMemo(
|
||||
() => !isLoading && db.notes.note(noteId)?.data,
|
||||
() => !isLoading && db.notes?.note(noteId)?.data,
|
||||
[noteId, isLoading]
|
||||
);
|
||||
const openLockedSession = useEditorStore((store) => store.openLockedSession);
|
||||
@@ -45,14 +48,18 @@ function Unlock(props) {
|
||||
const setIsEditorOpen = useAppStore((store) => store.setIsEditorOpen);
|
||||
|
||||
const submit = useCallback(async () => {
|
||||
if (!passwordRef.current) return;
|
||||
setIsUnlocking(true);
|
||||
const password = passwordRef.current.value;
|
||||
try {
|
||||
if (!password) return;
|
||||
const note = await db.vault.open(noteId, password);
|
||||
const note = await db.vault?.open(noteId, password);
|
||||
openLockedSession(note);
|
||||
} catch (e) {
|
||||
if (e.message.includes("ciphertext cannot be decrypted using that key")) {
|
||||
if (
|
||||
e instanceof Error &&
|
||||
e.message.includes("ciphertext cannot be decrypted using that key")
|
||||
) {
|
||||
setIsWrong(true);
|
||||
} else {
|
||||
showToast("error", "Cannot unlock note: " + e);
|
||||
@@ -122,7 +129,7 @@ function Unlock(props) {
|
||||
sx={{ width: ["95%", "95%", "30%"] }}
|
||||
placeholder="Enter password"
|
||||
type="password"
|
||||
onKeyUp={async (e) => {
|
||||
onKeyUp={async (e: KeyboardEvent) => {
|
||||
if (e.key === "Enter") {
|
||||
await submit();
|
||||
} else if (isWrong) {
|
||||
Reference in New Issue
Block a user