From e46e7b74e2c7c75592c0cc6df9bcc3221461df42 Mon Sep 17 00:00:00 2001 From: Araxeus Date: Sat, 8 May 2021 19:34:57 +0300 Subject: [PATCH] fix sendError() --- plugins/downloader/back.js | 6 +++--- plugins/downloader/menu.js | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/downloader/back.js b/plugins/downloader/back.js index aae5344d..43e385bb 100644 --- a/plugins/downloader/back.js +++ b/plugins/downloader/back.js @@ -10,7 +10,7 @@ const { cropMaxWidth } = require("./utils"); const { ACTIONS, CHANNEL } = require("./actions.js"); const { getImage } = require("../../providers/song-info"); -const sendError = (err) => { +const sendError = (win, err) => { const dialogOpts = { type: "info", buttons: ["OK"], @@ -34,7 +34,7 @@ function handle(win) { listenAction(CHANNEL, (event, action, arg) => { switch (action) { case ACTIONS.ERROR: //arg = error - sendError(arg); + sendError(win, arg); break; case ACTIONS.METADATA: event.returnValue = JSON.stringify(metadata); @@ -77,7 +77,7 @@ function handle(win) { writer.addTag(); fileBuffer = Buffer.from(writer.arrayBuffer); } catch (error) { - sendError(error); + sendError(win, error); } writeFileSync(filePath, fileBuffer); diff --git a/plugins/downloader/menu.js b/plugins/downloader/menu.js index b2dd5f25..f5b99d73 100644 --- a/plugins/downloader/menu.js +++ b/plugins/downloader/menu.js @@ -32,7 +32,7 @@ module.exports = (win, options) => { const currentURL = metadataURL || win.webContents.getURL(); const playlistID = new URL(currentURL).searchParams.get("list"); if (!playlistID) { - sendError(new Error("No playlist ID found")); + sendError(win, new Error("No playlist ID found")); return; } @@ -46,6 +46,7 @@ module.exports = (win, options) => { const playlistFolder = join(folder, playlistTitle); if (existsSync(playlistFolder)) { sendError( + win, new Error(`The folder ${playlistFolder} already exists`) ); return;