fix: Stop PTZ movement and browser key handling from fighting (#2674)
- Closes: #2623
This commit is contained in:
@@ -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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user