From ef575814d377f6bd3754767704d3f5520e30ba3e Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Sat, 4 Mar 2023 12:17:27 +0200 Subject: [PATCH] remove unused imports --- plugins/downloader/actions.js | 11 ----------- plugins/downloader/back.js | 19 +------------------ plugins/downloader/front.js | 17 +++-------------- 3 files changed, 4 insertions(+), 43 deletions(-) delete mode 100644 plugins/downloader/actions.js diff --git a/plugins/downloader/actions.js b/plugins/downloader/actions.js deleted file mode 100644 index 0d6c342648..0000000000 --- a/plugins/downloader/actions.js +++ /dev/null @@ -1,11 +0,0 @@ -const CHANNEL = "downloader"; -const ACTIONS = { - ERROR: "error", - METADATA: "metadata", - PROGRESS: "progress", -}; - -module.exports = { - CHANNEL: CHANNEL, - ACTIONS: ACTIONS, -}; diff --git a/plugins/downloader/back.js b/plugins/downloader/back.js index bb98067549..08c63c7b9e 100644 --- a/plugins/downloader/back.js +++ b/plugins/downloader/back.js @@ -3,9 +3,8 @@ const { join } = require("path"); const { dialog } = require("electron"); const registerCallback = require("../../providers/song-info"); -const { injectCSS, listenAction } = require("../utils"); +const { injectCSS } = require("../utils"); const { setBadge, sendFeedback } = require("./utils"); -const { ACTIONS, CHANNEL } = require("./actions.js"); let win = {}; @@ -37,22 +36,6 @@ function handle(win_, options) { registerCallback((info) => { nowPlayingMetadata = info; }); - - listenAction(CHANNEL, (event, action, arg) => { - switch (action) { - case ACTIONS.ERROR: // arg = error - sendError(arg); - break; - case ACTIONS.METADATA: - event.returnValue = JSON.stringify(nowPlayingMetadata); - break; - case ACTIONS.PROGRESS: // arg = progress - win.setProgressBar(arg); - break; - default: - console.log("Unknown action: " + action); - } - }); } module.exports = handle; diff --git a/plugins/downloader/front.js b/plugins/downloader/front.js index e534ed7137..3e50a7432d 100644 --- a/plugins/downloader/front.js +++ b/plugins/downloader/front.js @@ -2,8 +2,7 @@ const { ipcRenderer } = require("electron"); const { defaultConfig } = require("../../config"); const { getSongMenu } = require("../../providers/dom-elements"); -const { ElementFromFile, templatePath, triggerAction } = require("../utils"); -const { ACTIONS, CHANNEL } = require("./actions.js"); +const { ElementFromFile, templatePath } = require("../utils"); let menu = null; let progress = null; @@ -25,22 +24,12 @@ const observer = new MutationObserver(() => { progress = document.querySelector("#ytmcustom-download"); }); -const reinit = () => { - triggerAction(CHANNEL, ACTIONS.PROGRESS, -1); // closes progress bar - if (!progress) { - console.warn("Cannot update progress"); - } else { - progress.innerHTML = "Download"; - } -}; - const baseUrl = defaultConfig.url; // TODO: re-enable once contextIsolation is set to true // contextBridge.exposeInMainWorld("downloader", { // download: () => { global.download = () => { - //triggerAction(CHANNEL, ACTIONS.PROGRESS, 2); // starts with indefinite progress bar let metadata; let videoUrl = getSongMenu() // selector of first button which is always "Start Radio" @@ -60,7 +49,7 @@ global.download = () => { videoUrl = metadata.url || window.location.href; } - ipcRenderer.invoke('download-song', videoUrl)//.finally(() => triggerAction(CHANNEL, ACTIONS.PROGRESS, -1)); + ipcRenderer.invoke('download-song', videoUrl); return; }; @@ -74,7 +63,7 @@ function observeMenu(options) { }); }, { once: true, passive: true }) - ipcRenderer.on('downloader-feedback', (_, feedback)=> { + ipcRenderer.on('downloader-feedback', (_, feedback) => { if (!progress) { console.warn("Cannot update progress"); } else {