feat: Capture ctx.updateStatus to correctly reflect timer completion status.
This commit is contained in:
@@ -185,8 +185,11 @@ export default {
|
|||||||
// Normal mode - schedule light to turn on after stored duration
|
// Normal mode - schedule light to turn on after stored duration
|
||||||
ctx.log(`Light off. Will turn on in ${state.storedDuration}ms`);
|
ctx.log(`Light off. Will turn on in ${state.storedDuration}ms`);
|
||||||
|
|
||||||
|
// Capture updateStatus for use in timer callback
|
||||||
|
const updateStatus = ctx.updateStatus;
|
||||||
|
|
||||||
// Push status update to dashboard
|
// Push status update to dashboard
|
||||||
ctx.updateStatus({
|
updateStatus({
|
||||||
storedDuration: state.storedDuration,
|
storedDuration: state.storedDuration,
|
||||||
countMode: false,
|
countMode: false,
|
||||||
timerActive: true,
|
timerActive: true,
|
||||||
@@ -198,8 +201,13 @@ export default {
|
|||||||
await setLight(ctx, mac, true, 20);
|
await setLight(ctx, mac, true, 20);
|
||||||
state.timer = null;
|
state.timer = null;
|
||||||
|
|
||||||
// Can't use ctx.updateStatus here since ctx is out of scope
|
// Push timer completed status
|
||||||
// The timer completing will be reflected in next getStatus() call
|
updateStatus({
|
||||||
|
storedDuration: state.storedDuration,
|
||||||
|
countMode: false,
|
||||||
|
timerActive: false,
|
||||||
|
lastAction: 'Timer completed'
|
||||||
|
});
|
||||||
}, state.storedDuration);
|
}, state.storedDuration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user