fix: Stop a released PTZ key ending another held key's movement (#2675)
- Closes: #2668
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user