From 6b88397f820eee0d94cbc4f4bef7f420f1ac2468 Mon Sep 17 00:00:00 2001 From: Araxeus Date: Sat, 8 May 2021 21:21:07 +0300 Subject: [PATCH] lint --- plugins/downloader/back.js | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/plugins/downloader/back.js b/plugins/downloader/back.js index 9d7b95b6..76a77b92 100644 --- a/plugins/downloader/back.js +++ b/plugins/downloader/back.js @@ -10,16 +10,15 @@ const { cropMaxWidth } = require("./utils"); const { ACTIONS, CHANNEL } = require("./actions.js"); const { getImage } = require("../../providers/song-info"); -const sendError = (win, err) => { - const dialogOpts = { +const sendError = (win, error) => { + win.setProgressBar(-1); // close progress bar + dialog.showMessageBox({ type: "info", buttons: ["OK"], title: "Error in download!", message: "Argh! Apologies, download failed…", - detail: err.toString(), - }; - win.setProgressBar(-1); // close progress bar - dialog.showMessageBox(dialogOpts); + detail: error.toString(), + }); }; let nowPlayingMetadata = {}; @@ -33,13 +32,13 @@ function handle(win) { listenAction(CHANNEL, (event, action, arg) => { switch (action) { - case ACTIONS.ERROR: //arg = error + case ACTIONS.ERROR: // arg = error sendError(win, arg); break; case ACTIONS.METADATA: event.returnValue = JSON.stringify(nowPlayingMetadata); break; - case ACTIONS.PROGRESS: //arg = progress + case ACTIONS.PROGRESS: // arg = progress win.setProgressBar(arg); break; default: @@ -49,15 +48,12 @@ function handle(win) { ipcMain.on("add-metadata", async (event, filePath, songBuffer, currentMetadata) => { let fileBuffer = songBuffer; - let songMetadata; - if (currentMetadata.imageSrcYTPL) { // means metadata come from ytpl.getInfo(); - songMetadata = { + const songMetadata = currentMetadata.imageSrcYTPL ? // This means metadata come from ytpl.getInfo(); + { ...currentMetadata, image: cropMaxWidth(await getImage(currentMetadata.imageSrcYTPL)) - }; - } else { - songMetadata = { ...nowPlayingMetadata, ...currentMetadata }; - } + } : + { ...nowPlayingMetadata, ...currentMetadata }; try { const coverBuffer = songMetadata.image ? songMetadata.image.toPNG() : null; @@ -71,7 +67,7 @@ function handle(win) { writer.setFrame("APIC", { type: 3, data: coverBuffer, - description: "", + description: "" }); } writer.addTag();