Skip to content

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

call downloadMedia on content if previewing note in editor

Ammar Ahmeda2f690404e6d
diff --git a/apps/mobile/src/components/mergeconflicts/index.js b/apps/mobile/src/components/mergeconflicts/index.js
index 25b666bd8..edf7bd8e4 100644
--- a/apps/mobile/src/components/mergeconflicts/index.js
+++ b/apps/mobile/src/components/mergeconflicts/index.js
@@ -270,7 +270,13 @@ const MergeConflicts = () => {
onLoad={() => {
const note = db.notes.note(content.current?.noteId)?.data;
if (!note) return;
- eSendEvent(eOnLoadNote + ':conflictPrimary', { ...note, content: content.current });
+ eSendEvent(eOnLoadNote + ':conflictPrimary', {
+ ...note,
+ content: {
+ ...content.current,
+ isPreview: true
+ }
+ });
}}
/>
</Animated.View>
@@ -300,7 +306,7 @@ const MergeConflicts = () => {
if (!note) return;
eSendEvent(eOnLoadNote + ':conflictSecondary', {
...note,
- content: content.current.conflicted
+ content: { ...content.current.conflicted, isPreview: true }
});
}}
/>
diff --git a/apps/mobile/src/components/notehistory/preview.js b/apps/mobile/src/components/notehistory/preview.js
index 687360df3..b98b27057 100644
--- a/apps/mobile/src/components/notehistory/preview.js
+++ b/apps/mobile/src/components/notehistory/preview.js
@@ -58,7 +58,13 @@ export default function NotePreview({ session, content }) {
editorId={editorId}
onLoad={() => {
const note = db.notes.note(session.noteId)?.data;
- eSendEvent(eOnLoadNote + editorId, { ...note, content });
+ eSendEvent(eOnLoadNote + editorId, {
+ ...note,
+ content: {
+ ...content,
+ isPreview: true
+ }
+ });
}}
/>
</>
diff --git a/apps/mobile/src/screens/editor/tiptap/useEditor.ts b/apps/mobile/src/screens/editor/tiptap/useEditor.ts
index e3eb0793f..39935a03e 100644
--- a/apps/mobile/src/screens/editor/tiptap/useEditor.ts
+++ b/apps/mobile/src/screens/editor/tiptap/useEditor.ts
@@ -262,6 +262,7 @@ export const useEditor = (
useEditorStore.getState().setReadonly(item.readonly);
loadImages();
await commands.setTags(currentNote.current);
+ await commands.setSettings();
overlay(false);
}
},
@@ -270,9 +271,14 @@ export const useEditor = (
const loadImages = () => {
if (!currentNote.current?.id) return;
- const images = db.attachments?.ofNote(currentNote.current?.id, 'images');
- if (images && images.length > 0) {
- db.attachments?.downloadImages(currentNote.current.id);
+ //@ts-ignore
+ if (currentNote.current?.content?.isPreview) {
+ db.content?.downloadMedia(currentNote.current?.id, currentNote.current.content, true);
+ } else {
+ const images = db.attachments?.ofNote(currentNote.current?.id, 'images');
+ if (images && images.length > 0) {
+ db.attachments?.downloadImages(currentNote.current.id);
+ }
}
};
diff --git a/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts b/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts
index 396cb2e7d..d78189f88 100644
--- a/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts
+++ b/apps/mobile/src/screens/editor/tiptap/useEditorEvents.ts
@@ -154,10 +154,6 @@ export const useEditorEvents = (
editorState().movedAway = true;
tabBarRef.current?.goToPage(0);
}
- eSendEvent('historyEvent', {
- undo: 0,
- redo: 0
- });
setImmediate(() => useEditorStore.getState().setCurrentlyEditingNote(null));
editorState().currentlyEditing = false;
editor.reset();