Skip to content

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

mobile: prevent dropping uncompressed image attachments on new notes

kashaf-ansari-dev9e74404ee02f
diff --git a/apps/mobile/app/screens/editor/tiptap/picker.ts b/apps/mobile/app/screens/editor/tiptap/picker.ts
index 31dfaa45f..da7b3dbdb 100644
--- a/apps/mobile/app/screens/editor/tiptap/picker.ts
+++ b/apps/mobile/app/screens/editor/tiptap/picker.ts
@@ -123,10 +123,19 @@ const file = async (fileOptions: PickerOptions) => {
console.log(e, "error");
});
+ const currentFileNoteId =
+ fileOptions.tabId !== undefined
+ ? useTabStore.getState().getNoteIdForTab(fileOptions.tabId)
+ : undefined;
+
+ if (!fileOptions.noteId && currentFileNoteId) {
+ fileOptions.noteId = currentFileNoteId;
+ }
+
if (
fileOptions.tabId !== undefined &&
- useTabStore.getState().getNoteIdForTab(fileOptions.tabId) ===
- fileOptions.noteId
+ (currentFileNoteId === fileOptions.noteId ||
+ fileOptions.noteId === undefined)
) {
editorController.current?.commands.insertAttachment(
{
@@ -245,6 +254,7 @@ const handleImageResponse = async (
response: Image[],
options: PickerOptions
) => {
+ const isNewNote = options.noteId === undefined;
const result = await AttachImage.present(response, options.context);
if (!result) return;
@@ -295,9 +305,16 @@ const handleImageResponse = async (
RNFetchBlob.fs.unlink(uri).catch((e) => {});
+ const currentNoteId =
+ options.tabId !== undefined
+ ? useTabStore.getState().getNoteIdForTab(options.tabId)
+ : undefined;
+
+ const isSameNote = currentNoteId === options.noteId;
+
if (
options.tabId !== undefined &&
- useTabStore.getState().getNoteIdForTab(options.tabId) === options.noteId
+ (isSameNote || isNewNote)
) {
editorController.current?.commands.insertImage(
{