Skip to content

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

web: handle crash when drag-n-drop file in flatpak build (#9379)

01zulfi3e412323eef7
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index 426212fde..159e77253 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -784,14 +784,21 @@ function DropZone(props: DropZoneProps) {
display: "none"
}}
onDrop={async (e) => {
- const { activeEditorId, getEditor } = useEditorManager.getState();
- const editor = getEditor(activeEditorId || "")?.editor;
- if (!e.dataTransfer.files?.length || !editor) return;
-
- e.preventDefault();
- const attachments = await attachFiles(Array.from(e.dataTransfer.files));
- for (const attachment of attachments || []) {
- editor.attachFile(attachment);
+ try {
+ const { activeEditorId, getEditor } = useEditorManager.getState();
+ const editor = getEditor(activeEditorId || "")?.editor;
+ if (!e.dataTransfer.files?.length || !editor) return;
+
+ e.preventDefault();
+ const attachments = await attachFiles(
+ Array.from(e.dataTransfer.files)
+ );
+ for (const attachment of attachments || []) {
+ editor.attachFile(attachment);
+ }
+ } catch (e) {
+ logger.error(e as Error, "Failed to attach file from drag and drop");
+ showToast("error", strings.failedToAttachFile());
}
}}
>
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 126ea105a..8bb2c7bef 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -2761,6 +2761,10 @@ msgstr "Faced an issue or have a suggestion? Click here to create a bug report"
msgid "Failed"
msgstr "Failed"
+#: src/strings.ts:2637
+msgid "Failed to attach file"
+msgstr "Failed to attach file"
+
#: src/strings.ts:1936
msgid "Failed to copy note"
msgstr "Failed to copy note"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index dbec15550..285c7bff4 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -2750,6 +2750,10 @@ msgstr ""
msgid "Failed"
msgstr ""
+#: src/strings.ts:2637
+msgid "Failed to attach file"
+msgstr ""
+
#: src/strings.ts:1936
msgid "Failed to copy note"
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 663411f9b..4d5260757 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2634,5 +2634,6 @@ Use this if changes from other devices are not appearing on this device. This wi
importCsv: () => t`Import CSV`,
noContent: () => t`This note is empty`,
deleteData: () => t`Delete data`,
+ failedToAttachFile: () => t`Failed to attach file`,
unlockNoteToMergeConflicts: () => t`Unlock note to merge conflicts`
};