fix: Stop a released PTZ key ending another held key's movement (#2675)

- Closes: #2668
This commit is contained in:
Dermot Duffy
2026-08-10 20:22:39 -07:00
committed by GitHub
parent 3808a1b030
commit 70ca0a9af4
6 changed files with 337 additions and 33 deletions
@@ -31,14 +31,20 @@ export const replaceInProgressForThisTarget = async (
await replaced?.stop();
};
// The removal is made before the stop is awaited, so an action that registers
// for this target meanwhile is left in place.
// `matcher` decides whether the in-progress action is one this caller may
// stop; on a mismatch the action is left running. Without a matcher, whatever
// is in progress is stopped. The removal is made before the stop is awaited,
// so an action that registers for this target meanwhile is left in place.
export const clearInProgressForThisTarget = async (
targetID: string,
context: ActionContext,
contextKey: keyof ActionContext,
matcher?: (incumbent: Action) => boolean,
): Promise<void> => {
const stopped = context[contextKey]?.[targetID]?.inProgressAction;
if (!stopped || (matcher && !matcher(stopped))) {
return;
}
delete context[contextKey]?.[targetID];
await stopped?.stop();
await stopped.stop();
};