From 1668cbb98a04263457a5be132b7b820d3266adcf Mon Sep 17 00:00:00 2001 From: aandrew-me Date: Sun, 20 Nov 2022 17:42:14 +0600 Subject: [PATCH] Add reload option --- html/preferences.html | 3 ++- main.js | 11 +++++---- src/preferences.js | 7 ++++++ src/translate_preferences.js | 45 ++++++++++++++++++++---------------- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/html/preferences.html b/html/preferences.html index dd9121f..9e4ddd2 100644 --- a/html/preferences.html +++ b/html/preferences.html @@ -14,6 +14,7 @@
+ Restart app Homepage
@@ -119,7 +120,7 @@

Preferences

diff --git a/main.js b/main.js index e445079..2dd61bb 100644 --- a/main.js +++ b/main.js @@ -24,7 +24,6 @@ function createWindow() { contextIsolation: false, }, }); - win.loadFile("html/index.html"); win.maximize(); // win.setMenu(null) @@ -67,9 +66,13 @@ app.whenReady().then(() => { } }); -ipcMain.on("restart", () => { - app.relaunch(); - app.exit(); +ipcMain.on("reload", () => { + if (win) { + win.reload(); + } + if (secondaryWindow) { + secondaryWindow.reload(); + } }); ipcMain.on("get-version", () => { diff --git a/src/preferences.js b/src/preferences.js index 596e11a..5854f75 100644 --- a/src/preferences.js +++ b/src/preferences.js @@ -103,5 +103,12 @@ getId("preferredAudioQuality").addEventListener("change", ()=>{ localStorage.setItem("preferredAudioQuality", preferredAudioQuality) = preferredAudioQuality }) +// Reload +function reload(){ + ipcRenderer.send("reload") +} +getId("restart").addEventListener("click", () =>{ + reload() +}) require("../src/translate_preferences") diff --git a/src/translate_preferences.js b/src/translate_preferences.js index f2ae3d8..a4622af 100644 --- a/src/translate_preferences.js +++ b/src/translate_preferences.js @@ -1,25 +1,30 @@ -function getId(id){ - return document.getElementById(id) +function getId(id) { + return document.getElementById(id); } -function querySelectorAll(element){ - return document.querySelectorAll(element) +function querySelectorAll(element) { + return document.querySelectorAll(element); } -var i18n = new(require('../translations/i18n')) +var i18n = new (require("../translations/i18n"))(); // Translating texts -getId("title").textContent = i18n.__("Preferences") -getId("back").textContent = i18n.__("Homepage") -getId("dlText").textContent = i18n.__("Download location") -getId("clText").innerHTML = i18n.__("Current download location - ") -getId("selectLocation").textContent = i18n.__("Select Download Location") -getId("transparentText").textContent = i18n.__("Enable transparent dark mode(only Linux, needs relaunch)") -getId("preferences").textContent = i18n.__("Preferences") -getId("selectLn").textContent = i18n.__("Select Language (Requires relaunch)") -getId("browserInfo").title = i18n.__("This option lets you download restricted content. You will get errors if cookies are not there") -getId("browserTxt").textContent = i18n.__("Select browser to use cookies from") -getId("none").textContent = i18n.__("None") -querySelectorAll(".autoTxt").forEach(item => { - item.textContent = i18n.__("Automatic") +getId("title").textContent = i18n.__("Preferences"); +getId("back").textContent = i18n.__("Homepage"); +getId("dlText").textContent = i18n.__("Download location"); +getId("clText").innerHTML = i18n.__("Current download location - "); +getId("selectLocation").textContent = i18n.__("Select Download Location"); +getId("transparentText").textContent = i18n.__( + "Enable transparent dark mode(only Linux, needs relaunch)" +); +getId("preferences").textContent = i18n.__("Preferences"); +getId("selectLn").textContent = i18n.__("Select Language (Requires relaunch)"); +getId("browserInfo").title = i18n.__( + "This option lets you download restricted content. You will get errors if cookies are not there" +); +getId("browserTxt").textContent = i18n.__("Select browser to use cookies from"); +getId("none").textContent = i18n.__("None"); +querySelectorAll(".autoTxt").forEach((item) => { + item.textContent = i18n.__("Automatic"); }); -getId("preferredAudioTxt").textContent = i18n.__("Preferred audio format") -getId("preferredVideoTxt").textContent = i18n.__("Preferred video quality") \ No newline at end of file +getId("preferredAudioTxt").textContent = i18n.__("Preferred audio format"); +getId("preferredVideoTxt").textContent = i18n.__("Preferred video quality"); +getId("restart").textContent = i18n.__("Restart app");