diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/electron/ipc-api/download.js | 10 | ||||
-rw-r--r-- | src/webview/lib/RecipeWebview.js | 2 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/electron/ipc-api/download.js b/src/electron/ipc-api/download.js index 16de66229..7f8718924 100644 --- a/src/electron/ipc-api/download.js +++ b/src/electron/ipc-api/download.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { ipcMain, dialog } from 'electron'; | 1 | import { ipcMain, dialog, BrowserWindow } from 'electron'; |
2 | import { download } from 'electron-dl'; | 2 | import { download } from 'electron-dl'; |
3 | import mime from 'mime-types'; | 3 | import mime from 'mime-types'; |
4 | import fs from 'fs-extra'; | 4 | import fs from 'fs-extra'; |
@@ -17,15 +17,11 @@ function decodeBase64Image(dataString) { | |||
17 | 17 | ||
18 | export default (params) => { | 18 | export default (params) => { |
19 | ipcMain.on('download-file', async (event, { url, content, fileOptions = {} }) => { | 19 | ipcMain.on('download-file', async (event, { url, content, fileOptions = {} }) => { |
20 | // We're passing a fake browserWindow to `electron-dl` in order to access the | 20 | const win = BrowserWindow.getFocusedWindow(); |
21 | // webContents of the webview that has initiated the download | ||
22 | const fakeWindow = { | ||
23 | webContents: event.sender.webContents, | ||
24 | }; | ||
25 | 21 | ||
26 | try { | 22 | try { |
27 | if (!content) { | 23 | if (!content) { |
28 | const dl = await download(fakeWindow, url, { | 24 | const dl = await download(win, url, { |
29 | saveAs: true, | 25 | saveAs: true, |
30 | }); | 26 | }); |
31 | debug('File saved to', dl.savePath); | 27 | debug('File saved to', dl.savePath); |
diff --git a/src/webview/lib/RecipeWebview.js b/src/webview/lib/RecipeWebview.js index bef4b78ef..84ac45ecc 100644 --- a/src/webview/lib/RecipeWebview.js +++ b/src/webview/lib/RecipeWebview.js | |||
@@ -74,7 +74,7 @@ class RecipeWebview { | |||
74 | */ | 74 | */ |
75 | injectCSS(...files) { | 75 | injectCSS(...files) { |
76 | files.forEach(async (file) => { | 76 | files.forEach(async (file) => { |
77 | if (await fs.exists(file)) { | 77 | if (fs.pathExistsSync(file)) { |
78 | const data = await fs.readFile(file, 'utf8'); | 78 | const data = await fs.readFile(file, 'utf8'); |
79 | const styles = document.createElement('style'); | 79 | const styles = document.createElement('style'); |
80 | styles.innerHTML = data; | 80 | styles.innerHTML = data; |