edgeclk: refactor step event handling

Only register event handler if we want to actually use the event.
pull/3582/head
thyttan 2024-09-23 22:23:15 +02:00
parent 7a47e33441
commit e8e24574b7
1 changed files with 3 additions and 4 deletions

View File

@ -281,10 +281,9 @@
}; };
const onStep = function () { const onStep = function () {
if (settings.redrawOnStep) drawSteps(); drawSteps();
} }
/* Lifecycle Functions /* Lifecycle Functions
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -305,7 +304,7 @@
Bangle.on('charging', onCharging); Bangle.on('charging', onCharging);
// Continously update step count when they happen: // Continously update step count when they happen:
Bangle.on('step', onStep); if (settings.redrawOnStep) Bangle.on('step', onStep);
}; };
const deregisterEvents = function () { const deregisterEvents = function () {
@ -314,7 +313,7 @@
Bangle.removeListener('health', onHealth); Bangle.removeListener('health', onHealth);
Bangle.removeListener('lock', onLock); Bangle.removeListener('lock', onLock);
Bangle.removeListener('charging', onCharging); Bangle.removeListener('charging', onCharging);
Bangle.removeListener('step', onStep); if (settings.redrawOnStep) Bangle.removeListener('step', onStep);
}; };
const startTimers = function () { const startTimers = function () {