web: handle crash when drag-n-drop file in flatpak build

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2026-02-20 16:41:29 +05:00
parent b20ad48b31
commit 912da1aee9
4 changed files with 24 additions and 8 deletions

View File

@@ -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;
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);
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());
}
}}
>

View File

@@ -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"

View File

@@ -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 ""

View File

@@ -2633,5 +2633,6 @@ Use this if changes from other devices are not appearing on this device. This wi
exportCsv: () => t`Export CSV`,
importCsv: () => t`Import CSV`,
noContent: () => t`This note is empty`,
deleteData: () => t`Delete data`
deleteData: () => t`Delete data`,
failedToAttachFile: () => t`Failed to attach file`
};