fix: Stop PTZ movement and browser key handling from fighting (#2674)

- Closes: #2623
This commit is contained in:
Dermot Duffy
2026-08-10 14:49:50 -07:00
committed by GitHub
parent a8aa9ec7c2
commit 3808a1b030
20 changed files with 822 additions and 148 deletions
@@ -1,16 +1,9 @@
import type { ActionContext } from 'action';
import { merge } from 'lodash-es';
import type { Action, TargetedActionContext } from '../types';
import type { Action } from '../types';
export const stopInProgressForThisTarget = async (
targetID: string,
context?: TargetedActionContext,
): Promise<void> => {
await context?.[targetID]?.inProgressAction?.stop();
};
export const setInProgressForThisTarget = (
const setInProgressForThisTarget = (
targetID: string,
context: ActionContext,
contextKey: keyof ActionContext,
@@ -24,3 +17,28 @@ export const setInProgressForThisTarget = (
},
});
};
// `action` is registered before the stop is awaited, so an action that starts
// for this target meanwhile sees `action`.
export const replaceInProgressForThisTarget = async (
targetID: string,
context: ActionContext,
contextKey: keyof ActionContext,
action: Action,
): Promise<void> => {
const replaced = context[contextKey]?.[targetID]?.inProgressAction;
setInProgressForThisTarget(targetID, context, contextKey, action);
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.
export const clearInProgressForThisTarget = async (
targetID: string,
context: ActionContext,
contextKey: keyof ActionContext,
): Promise<void> => {
const stopped = context[contextKey]?.[targetID]?.inProgressAction;
delete context[contextKey]?.[targetID];
await stopped?.stop();
};