From 9db363865c2facee7030f70c3b04fe40de20dbb2 Mon Sep 17 00:00:00 2001 From: milotodt Date: Fri, 5 Apr 2019 14:25:30 -0700 Subject: [PATCH] Slight refactor --- .../main/lib/dataApi/attachmentManagement.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/browser/main/lib/dataApi/attachmentManagement.js b/browser/main/lib/dataApi/attachmentManagement.js index 19cf5723..39c44ff6 100644 --- a/browser/main/lib/dataApi/attachmentManagement.js +++ b/browser/main/lib/dataApi/attachmentManagement.js @@ -278,19 +278,20 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) { let promise if (dropEvent.dataTransfer.files.length > 0) { promise = Promise.all(Array.from(dropEvent.dataTransfer.files).map(file => { - var filePath = file.path - if (file.type.startsWith('image')) { - if (file.type === 'image/gif' || file.type === 'image/svg+xml') { - return copyAttachment(file.path, storageKey, noteKey).then(fileName => ({ + const filePath = file.path + const fileType = file.type // EX) 'image/gif' or 'text/html' + if (fileType.startsWith('image')) { + if (fileType === 'image/gif' || fileType === 'image/svg+xml') { + return copyAttachment(filePath, storageKey, noteKey).then(fileName => ({ fileName, - title: path.basename(file.path), + title: path.basename(filePath), isImage: true })) } else { return getOrientation(file) .then((orientation) => { if (orientation === -1) { // The image rotation is correct and does not need adjustment - return copyAttachment(file.path, storageKey, noteKey) + return copyAttachment(filePath, storageKey, noteKey) } else { return fixRotate(file).then(data => copyAttachment({ type: 'base64', @@ -308,9 +309,9 @@ function handleAttachmentDrop (codeEditor, storageKey, noteKey, dropEvent) { ) } } else { - return copyAttachment(file.path, storageKey, noteKey).then(fileName => ({ + return copyAttachment(filePath, storageKey, noteKey).then(fileName => ({ fileName, - title: path.basename(file.path), + title: path.basename(filePath), isImage: false })) }