From 024be4ce890f347cc537c05b7014366473720d13 Mon Sep 17 00:00:00 2001 From: Ammar Ahmed Date: Fri, 23 Feb 2024 11:40:25 +0500 Subject: [PATCH] mobile: fix readonly mode --- apps/mobile/app/screens/editor/index.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx index d3b1ca015..d2c314b8e 100755 --- a/apps/mobile/app/screens/editor/index.tsx +++ b/apps/mobile/app/screens/editor/index.tsx @@ -102,7 +102,7 @@ const Editor = React.memo( useEffect(() => { const sub = [eSubscribeEvent("webview_reset", onError)]; return () => { - sub.forEach((s) => s.unsubscribe()); + sub.forEach((s) => s?.unsubscribe()); }; }, [onError]); @@ -179,9 +179,8 @@ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => { const onPress = async () => { if (editor.note.current) { - await db.notes.note(editor.note.current.id)?.readonly(); - editor.note.current = db.notes?.note(editor.note.current.id)?.data; - + await db.notes.readonly(false, editor.note.current.id); + editor.note.current = await db.notes?.note(editor.note.current.id); useEditorStore.getState().setReadonly(false); } };