Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

web: fix lock/unlock from properties not working

Abdullah Atta47862c318219
diff --git a/apps/web/src/components/properties/index.tsx b/apps/web/src/components/properties/index.tsx
index 98cb71e45..477f52e8a 100644
--- a/apps/web/src/components/properties/index.tsx
+++ b/apps/web/src/components/properties/index.tsx
@@ -114,7 +114,6 @@ function EditorProperties(props: EditorPropertiesProps) {
const session = useEditorStore((store) =>
store.getSession(props.session.id, [props.session.type])
);
- console.log(session);
if (isFocusMode || !session) return null;
return (
<AnimatedFlex
@@ -169,7 +168,11 @@ function EditorProperties(props: EditorPropertiesProps) {
<Toggle
{...tool}
key={tool.key}
- isOn={!!session.note[tool.property]}
+ isOn={
+ tool.property === "locked"
+ ? "locked" in session && !!session.locked
+ : !!session.note[tool.property]
+ }
onToggle={() => changeToggleState(tool.key, session)}
testId={`properties-${tool.key}`}
/>
@@ -720,18 +723,13 @@ function changeToggleState(
prop: "lock" | "readonly" | "local-only" | "pin" | "favorite",
session: ReadonlyEditorSession | DefaultEditorSession
) {
- const {
- id: sessionId,
- locked,
- readonly,
- localOnly,
- pinned,
- favorite
- } = session.note;
+ const { id: sessionId, readonly, localOnly, pinned, favorite } = session.note;
if (!sessionId) return;
switch (prop) {
case "lock":
- return locked ? noteStore.unlock(sessionId) : noteStore.lock(sessionId);
+ return "locked" in session && session.locked
+ ? noteStore.unlock(sessionId)
+ : noteStore.lock(sessionId);
case "readonly":
return noteStore.readonly(!readonly, sessionId);
case "local-only":