mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-23 19:49:56 +01:00
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:
@@ -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());
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
@@ -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`
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user