瀏覽代碼

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

Fixes #359
Danilo Bargen 7 年之前
父節點
當前提交
acf285243f
共有 1 個文件被更改,包括 8 次插入6 次删除
  1. 8 6
      src/services/battery.ts

+ 8 - 6
src/services/battery.ts

@@ -45,12 +45,14 @@ export class BatteryStatusService {
         this.batteryStatus = batteryStatus;
         this.batteryStatus = batteryStatus;
 
 
         // Alert if percent drops below a certain threshold
         // 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
         // Reset alert flag if percentage goes above a certain threshold