Skip to content

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

Fix: onNoteCreated is not reset after leaving a page

ammarahm-ed6b4ee3ef424e
diff --git a/apps/mobile/src/screens/editor/tiptap/commands.ts b/apps/mobile/src/screens/editor/tiptap/commands.ts
index 27eb3cabd..ad6347a3c 100644
--- a/apps/mobile/src/screens/editor/tiptap/commands.ts
+++ b/apps/mobile/src/screens/editor/tiptap/commands.ts
@@ -164,6 +164,14 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
`);
};
+ clearTags = async () => {
+ await this.doAsync(`
+ if (typeof editorTags !== "undefined" && editorTags.current) {
+ editorTags.current.setTags([]);
+ }
+ `);
+ };
+
insertAttachment = async (attachment: Attachment) => {
await this.doAsync(`editor && editor.commands.insertAttachment(${JSON.stringify(attachment)})`);
};
diff --git a/apps/mobile/src/screens/editor/tiptap/useEditor.ts b/apps/mobile/src/screens/editor/tiptap/useEditor.ts
index 52e0ad867..e9d94f5d2 100644
--- a/apps/mobile/src/screens/editor/tiptap/useEditor.ts
+++ b/apps/mobile/src/screens/editor/tiptap/useEditor.ts
@@ -121,6 +121,7 @@ export const useEditor = (
useEditorStore.getState().setReadonly(false);
postMessage(EditorEvents.title, '');
await commands.clearContent();
+ await commands.clearTags();
console.log('reset state: ', resetState);
if (resetState) {
isDefaultEditor && useEditorStore.getState().setCurrentlyEditingNote(null);
diff --git a/apps/mobile/src/screens/notes/common.ts b/apps/mobile/src/screens/notes/common.ts
index 6e01a64d9..f24609913 100644
--- a/apps/mobile/src/screens/notes/common.ts
+++ b/apps/mobile/src/screens/notes/common.ts
@@ -2,6 +2,7 @@ import { DDS } from '../../services/device-detection';
import { eSendEvent } from '../../services/event-manager';
import Navigation, { NotesScreenParams } from '../../services/navigation';
import { useMenuStore } from '../../stores/use-menu-store';
+import { useTagStore } from '../../stores/use-tag-store';
import { db } from '../../utils/database';
import { eOnLoadNote } from '../../utils/events';
import { openLinkInBrowser } from '../../utils/functions';
@@ -103,7 +104,7 @@ async function onNoteCreated(id: string, params: FirstSaveData) {
'Favorites',
'Notes'
);
- eSendEvent('updateTags');
+ useTagStore.getState().setTags();
break;
}
case 'color': {
diff --git a/apps/mobile/src/screens/notes/index.tsx b/apps/mobile/src/screens/notes/index.tsx
index 80b8c848e..d6d3b79a8 100644
--- a/apps/mobile/src/screens/notes/index.tsx
+++ b/apps/mobile/src/screens/notes/index.tsx
@@ -151,6 +151,7 @@ const NotesPage = ({
useEffect(() => {
eSubscribeEvent(route.name, onRequestUpdate);
return () => {
+ setOnFirstSave(null);
eUnSubscribeEvent(route.name, onRequestUpdate);
};
}, []);