aboutsummaryrefslogtreecommitdiff
path: root/src/app/js/request.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/js/request.js')
-rw-r--r--src/app/js/request.js12
1 files changed, 9 insertions, 3 deletions
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) => {