Skip to content

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

mobile: fix image replaces content if note is locked & app lock is also enabled

ammarahm-eda3988fd30925
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index 07537ef7b..9243c5d58 100644
--- a/apps/mobile/app/screens/editor/tiptap/types.ts
+++ b/apps/mobile/app/screens/editor/tiptap/types.ts
@@ -35,6 +35,7 @@ export type EditorState = {
keyboardState: boolean;
ready: boolean;
saveCount: 0;
+ isAwaitingResult: boolean;
};
export type Settings = {
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
index 3d57d90c4..e7076bb30 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
@@ -248,8 +248,11 @@ export const useEditorEvents = (
}
});
}, [onHardwareBackPress]);
- const onCallClear = useCallback(
+
+ const onClearEditorSessionRequest = useCallback(
async (value: string) => {
+ if (editorState()?.isAwaitingResult) return;
+
if (value === "removeHandler") {
if (handleBack.current) {
handleBack.current.remove();
@@ -291,12 +294,15 @@ export const useEditorEvents = (
useEffect(() => {
eSubscribeEvent(eOnLoadNote + editor.editorId, onLoadNote);
- eSubscribeEvent(eClearEditor + editor.editorId, onCallClear);
+ eSubscribeEvent(
+ eClearEditor + editor.editorId,
+ onClearEditorSessionRequest
+ );
return () => {
- eUnSubscribeEvent(eClearEditor, onCallClear);
+ eUnSubscribeEvent(eClearEditor, onClearEditorSessionRequest);
eUnSubscribeEvent(eOnLoadNote, onLoadNote);
};
- }, [editor.editorId, onCallClear, onLoadNote]);
+ }, [editor.editorId, onClearEditorSessionRequest, onLoadNote]);
const onMessage = useCallback(
(event: WebViewMessageEvent) => {
@@ -374,8 +380,12 @@ export const useEditorEvents = (
}
break;
case EventTypes.filepicker:
+ editorState().isAwaitingResult = true;
const { pick } = require("./picker.js").default;
pick({ type: editorMessage.value });
+ setTimeout(() => {
+ editorState().isAwaitingResult = false;
+ }, 1000);
break;
case EventTypes.download: {
const downloadAttachment =
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index a134402c6..ee5413306 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -206,7 +206,6 @@ export const useEditor = (
type: type
};
}
-
if (!locked) {
id = await db.notes?.add(noteData);
if (!note && id) {