aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-06-12 23:46:38 +0530
committerLibravatar GitHub <noreply@github.com>2021-06-12 20:16:38 +0200
commitc903ac821469a807a9958cdbd23ae77763db1435 (patch)
treeee9b299355602347e7c04f9d1361046729b89423 /src/electron
parentFix active Todos service behaviour (#1481) (diff)
downloadferdium-app-c903ac821469a807a9958cdbd23ae77763db1435.tar.gz
ferdium-app-c903ac821469a807a9958cdbd23ae77763db1435.tar.zst
ferdium-app-c903ac821469a807a9958cdbd23ae77763db1435.zip
Upgraded some modules (#1520)
Diffstat (limited to 'src/electron')
-rw-r--r--src/electron/ipc-api/download.js10
1 files changed, 3 insertions, 7 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 @@
1import { ipcMain, dialog } from 'electron'; 1import { ipcMain, dialog, BrowserWindow } from 'electron';
2import { download } from 'electron-dl'; 2import { download } from 'electron-dl';
3import mime from 'mime-types'; 3import mime from 'mime-types';
4import fs from 'fs-extra'; 4import fs from 'fs-extra';
@@ -17,15 +17,11 @@ function decodeBase64Image(dataString) {
17 17
18export default (params) => { 18export 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);