aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2024-08-04 14:27:54 +0200
committerJan200101 <sentrycraft123@gmail.com>2024-08-04 14:27:54 +0200
commit558ef98614b8ad34ba4fb35a8f0b6fe94211f938 (patch)
tree4e3a6fb02fde6c270cb0824945ab3e1d81af9934 /src/app
parent5d6ab8e481fe6df98f0bb345589d0b1ccb291f88 (diff)
downloadViper-558ef98614b8ad34ba4fb35a8f0b6fe94211f938.tar.gz
Viper-558ef98614b8ad34ba4fb35a8f0b6fe94211f938.zip
handle onLine event dynamically, don't enable buttons when going offline
Diffstat (limited to 'src/app')
-rw-r--r--src/app/js/browser.js1
-rw-r--r--src/app/js/request.js12
2 files changed, 9 insertions, 4 deletions
diff --git a/src/app/js/browser.js b/src/app/js/browser.js
index 3415ebf..c559031 100644
--- a/src/app/js/browser.js
+++ b/src/app/js/browser.js
@@ -524,7 +524,6 @@ ipcRenderer.on("legacy-duped-mod", (_, modname) => {
})
ipcRenderer.on("no-internet", () => {
- set_buttons(true);
toasts.show({
timeout: 10000,
scheme: "error",
diff --git a/src/app/js/request.js b/src/app/js/request.js
index 29b8883..aeea35a 100644
--- a/src/app/js/request.js
+++ b/src/app/js/request.js
@@ -1,10 +1,16 @@
const ipcRenderer = require("electron").ipcRenderer;
-// show a toast message if no Internet connection has been detected.
-if (! navigator.onLine) {
- ipcRenderer.send("no-internet");
+const updateOnlineStatus = () => {
+ // show a toast message if no Internet connection has been detected.
+ if (!navigator.onLine) {
+ ipcRenderer.send("no-internet");
+ }
}
+window.addEventListener('online', updateOnlineStatus);
+window.addEventListener('offline', updateOnlineStatus);
+updateOnlineStatus();
+
// invokes `requests.get()` from `src/modules/requests.js` through the
// main process, and returns the output
let request = async (...args) => {