Make low battery thresholds inclusive and support multiple $POWER_LEVEL replacements (#611)
Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
@@ -29,19 +29,19 @@ export function warnOnLowBattery(): void {
|
|||||||
// To avoid double notifications, we check each of the thresholds and set the correct `sentNotification`, but then
|
// To avoid double notifications, we check each of the thresholds and set the correct `sentNotification`, but then
|
||||||
// combine them into one notification only
|
// combine them into one notification only
|
||||||
let sendNotification = false;
|
let sendNotification = false;
|
||||||
if (!sentLowNotification && batteryPercentage < lowThreshold) {
|
if (!sentLowNotification && batteryPercentage <= lowThreshold) {
|
||||||
sentLowNotification = true;
|
sentLowNotification = true;
|
||||||
sendNotification = true;
|
sendNotification = true;
|
||||||
}
|
}
|
||||||
if (!sentHalfLowNotification && batteryPercentage < lowThreshold / 2) {
|
if (!sentHalfLowNotification && batteryPercentage <= lowThreshold / 2) {
|
||||||
sentHalfLowNotification = true;
|
sentHalfLowNotification = true;
|
||||||
sendNotification = true;
|
sendNotification = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sendNotification) {
|
if (sendNotification) {
|
||||||
Notify({
|
Notify({
|
||||||
summary: lowBatteryNotificationTitle.get().replace('$POWER_LEVEL', batteryPercentage.toString()),
|
summary: lowBatteryNotificationTitle.get().replaceAll('$POWER_LEVEL', batteryPercentage.toString()),
|
||||||
body: lowBatteryNotificationText.get().replace('$POWER_LEVEL', batteryPercentage.toString()),
|
body: lowBatteryNotificationText.get().replaceAll('$POWER_LEVEL', batteryPercentage.toString()),
|
||||||
iconName: icons.ui.warning,
|
iconName: icons.ui.warning,
|
||||||
urgency: 'critical',
|
urgency: 'critical',
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user