1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-24 12:13:16 +00:00

Updated windows to not send the initial event on newListener for acdc, because windows acpi will already do this

This commit is contained in:
Bryan Roe
2020-05-31 00:16:41 -07:00
parent 5f1ca444a5
commit bfaddfaee2
2 changed files with 6 additions and 4 deletions

View File

@@ -36,8 +36,11 @@ function powerMonitor()
this.on('newListener', function (name, callback)
{
if (name == 'acdc') { callback.call(this, this._ACState == 1 ? 'AC' : 'BATTERY'); }
if (name == 'batteryLevel') { callback.call(this, this._BatteryLevel); }
if (process.platform != 'win32')
{ // Windows will already sends an initial event when you hookup the ACPI event, so this would be redundant
if (name == 'acdc') { callback.call(this, this._ACState == 1 ? 'AC' : 'BATTERY'); }
}
if (name == 'batteryLevel') { if (this._BatteryLevel >= 0) { callback.call(this, this._BatteryLevel); } }
});
this._i = setImmediate(function (self)