fix: Ensure a bare ptz_digital action resets the zoom (#2635)

- Closes: #2632
This commit is contained in:
Dermot Duffy
2026-07-29 23:18:06 -07:00
committed by GitHub
parent e9e6d9f833
commit a736f3dfaf
14 changed files with 258 additions and 113 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import type { ViewModifier } from '../types';
export const applyViewModifiers = (
view: View,
modifiers?: ViewModifier[] | null,
): void => {
): View => {
modifiers?.forEach((modifier) => modifier.modify(view));
return view;
};
@@ -0,0 +1,30 @@
import type { PartialZoomSettings } from '../../../components-lib/zoom/types';
import { generateViewContextForZoom } from '../../../components-lib/zoom/zoom-view-context';
import type { View } from '../../../view/view';
import type { ViewModifier } from '../types';
// The single write path for a zoom request. The settings are *assigned* rather than
// *merged*, so a new request always replaces the one before it. This is
// necessary as a request to reset to default is expressed as an empty object,
// and a deep merge cannot use that to *erase* the values of an earlier request.
export class ZoomRequestViewModifier implements ViewModifier {
private _targetID: string;
private _requested: PartialZoomSettings;
constructor(targetID: string, requested: PartialZoomSettings) {
this._targetID = targetID;
this._requested = requested;
}
public modify(view: View): void {
const target = view.context?.zoom?.[this._targetID];
if (target) {
target.requested = this._requested;
return;
}
view.mergeInContext(
generateViewContextForZoom(this._targetID, { requested: this._requested }),
);
}
}
+1
View File
@@ -82,6 +82,7 @@ export interface ViewManagerInterface {
setViewByParametersWithExistingQuery(options?: ViewFactoryOptions): Promise<void>;
setViewWithMergedContext(context: ViewContext | null): void;
setViewWithModifiers(modifiers: ViewModifier[]): void;
hasMajorMediaChange(oldView?: View | null, newView?: View | null): boolean;
}
+6
View File
@@ -334,6 +334,12 @@ export class ViewManager implements ViewManagerInterface {
}
}
public setViewWithModifiers(modifiers: ViewModifier[]): void {
if (this._view) {
return this._setView(applyViewModifiers(this._view.clone(), modifiers));
}
}
/**
* Detect if the current view has a major "media change" for the given previous view.
* @param oldView The previous view.