feat: Implement support for gesture-based PTZ control (#2378)
- Closes: #1839
This commit is contained in:
@@ -6,8 +6,25 @@ export class PTZControlsAction extends AdvancedCameraCardAction<PTZControlsActio
|
||||
public async execute(api: CardActionsAPI): Promise<void> {
|
||||
await super.execute(api);
|
||||
|
||||
const currentEnabled = api.getViewManager().getView()?.context?.ptzControls?.enabled;
|
||||
|
||||
// If `enabled` is explicit, use it. If only `type` is being changed, leave
|
||||
// `enabled` untouched (undefined = no change). Otherwise (neither set),
|
||||
// toggle the current enabled value — this is the menu-button show/hide use
|
||||
// case.
|
||||
const enabled =
|
||||
this._action.enabled ??
|
||||
(this._action.type
|
||||
? undefined
|
||||
: currentEnabled === undefined
|
||||
? undefined
|
||||
: !currentEnabled);
|
||||
|
||||
api.getViewManager().setViewWithMergedContext({
|
||||
ptzControls: { enabled: this._action.enabled },
|
||||
ptzControls: {
|
||||
...(enabled !== undefined && { enabled }),
|
||||
...(this._action.type && { type: this._action.type }),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user