Browse Source

fix(toolbar/state): guard against mining in background on power/online change

fixes #25
Josh Habdas 10 months ago
parent
commit
74ae2cf15b
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74
1 changed files with 4 additions and 0 deletions
  1. 4
    0
      layouts/partials/modules/toxic-swamp/toolbar.html

+ 4
- 0
layouts/partials/modules/toxic-swamp/toolbar.html View File

@@ -327,6 +327,8 @@
327 327
       const handleChargingChange = evt => {
328 328
         const shouldMine = SessionManager.shouldMine;
329 329
         if (!shouldMine) return;
330
+        const isDocumentVisible = document.visibilityState === 'visible';
331
+        if (!isDocumentVisible) return;
330 332
         const isMinerActive = Actuator.status === 'active';
331 333
         const startedCharging = evt.target.charging;
332 334
         const isDeviceOnline = navigator.onLine;
@@ -351,6 +353,8 @@
351 353
       const handleOnlineChange = evt => {
352 354
         const shouldMine = SessionManager.shouldMine;
353 355
         if (!shouldMine) return;
356
+        const isDocumentVisible = document.visibilityState === 'visible';
357
+        if (!isDocumentVisible) return;
354 358
         const isMinerActive = Actuator.status === 'active';
355 359
         const wentOnline = evt.type === 'online';
356 360
         if (wentOnline) {

Loading…
Cancel
Save