Skip to content

Commit

Permalink
remove unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Araxeus committed Mar 4, 2023
1 parent 099e5d8 commit ef57581
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 43 deletions.
11 changes: 0 additions & 11 deletions plugins/downloader/actions.js

This file was deleted.

19 changes: 1 addition & 18 deletions plugins/downloader/back.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -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;
Expand Down
17 changes: 3 additions & 14 deletions plugins/downloader/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"
Expand All @@ -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;
};

Expand All @@ -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 {
Expand Down

0 comments on commit ef57581

Please sign in to comment.