Pārlūkot izejas kodu

Don't display low battery notification when charging (#360)

Fixes #359
Danilo Bargen 7 gadi atpakaļ
vecāks
revīzija
acf285243f
1 mainītis faili ar 8 papildinājumiem un 6 dzēšanām
  1. 8 6
      src/services/battery.ts

+ 8 - 6
src/services/battery.ts

@@ -45,12 +45,14 @@ export class BatteryStatusService {
         this.batteryStatus = batteryStatus;
 
         // Alert if percent drops below a certain threshold
-        if (!this.alertedCritical && batteryStatus.percent < BatteryStatusService.PERCENT_CRITICAL) {
-            this.notifyLevel('critical');
-            this.alertedCritical = true;
-        } else if (!this.alertedLow && batteryStatus.percent < BatteryStatusService.PERCENT_LOW) {
-            this.notifyLevel('low');
-            this.alertedLow = true;
+        if (!batteryStatus.isCharging) {
+            if (!this.alertedCritical && batteryStatus.percent < BatteryStatusService.PERCENT_CRITICAL) {
+                this.notifyLevel('critical');
+                this.alertedCritical = true;
+            } else if (!this.alertedLow && batteryStatus.percent < BatteryStatusService.PERCENT_LOW) {
+                this.notifyLevel('low');
+                this.alertedLow = true;
+            }
         }
 
         // Reset alert flag if percentage goes above a certain threshold