From 6a1f6d4728cf8d2499872d100cea28cb4f27d4ef Mon Sep 17 00:00:00 2001
From: Andrew <66430340+aandrew-me@users.noreply.github.com>
Date: Sat, 11 Mar 2023 12:28:55 +0600
Subject: [PATCH] Ability to change download directory in homepage
---
html/index.html | 8 ++++++++
main.js | 8 +++++++-
src/preferences.js | 6 +++---
src/renderer.js | 12 ++++++++++++
4 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/html/index.html b/html/index.html
index 02c6d3a..fca8c9e 100644
--- a/html/index.html
+++ b/html/index.html
@@ -37,6 +37,7 @@
+
@@ -115,6 +116,13 @@
title="If kept empty, it will be downloaded to the end">
+
+
+
Current download location -
+
+
+
+
Download subtitles if available
diff --git a/main.js b/main.js
index e9b91c4..b10ee83 100644
--- a/main.js
+++ b/main.js
@@ -227,7 +227,13 @@ ipcMain.on("select-location", () => {
});
if (location) {
- secondaryWindow.webContents.send("downloadPath", location);
+ if (secondaryWindow){
+ secondaryWindow.webContents.send("downloadPath", location);
+ }
+ else{
+ win.webContents.send("downloadPath", location);
+ }
+
}
});
diff --git a/src/preferences.js b/src/preferences.js
index 86b8531..09f919c 100644
--- a/src/preferences.js
+++ b/src/preferences.js
@@ -30,9 +30,9 @@ getId("selectLocation").addEventListener("click", () => {
});
ipcRenderer.on("downloadPath", (event, downloadPath) => {
- console.log(downloadPath);
- localStorage.setItem("downloadPath", downloadPath);
- getId("path").textContent = downloadPath;
+ console.log(downloadPath[0]);
+ localStorage.setItem("downloadPath", downloadPath[0]);
+ getId("path").textContent = downloadPath[0];
});
const enabledTransparent = getId("enableTransparent");
diff --git a/src/renderer.js b/src/renderer.js
index d3d159e..f0e7e1a 100644
--- a/src/renderer.js
+++ b/src/renderer.js
@@ -89,6 +89,7 @@ function downloadPathSelection() {
downloadDir = appdir;
localStorage.setItem("downloadPath", appdir);
}
+ getId("path").textContent = downloadDir;
fs.mkdir(downloadDir, { recursive: true }, () => {});
}
@@ -1168,3 +1169,14 @@ getId("newPlaylistWin").addEventListener("click", () => {
ipcRenderer.on("link", (event, text) => {
pasteFromTray(text);
});
+
+// Selecting download directory
+getId("selectLocation").addEventListener("click", () => {
+ ipcRenderer.send("select-location", "");
+});
+
+ipcRenderer.on("downloadPath", (event, downloadPath) => {
+ console.log(downloadPath);
+ getId("path").textContent = downloadPath;
+ downloadDir = downloadPath[0]
+});
\ No newline at end of file