Implement selectBestViewForNonFrigateCameras
This commit is contained in:
+5
-8
@@ -1246,19 +1246,16 @@ export class FrigateCard extends LitElement {
|
|||||||
case 'camera_select':
|
case 'camera_select':
|
||||||
const camera = frigateCardAction.camera;
|
const camera = frigateCardAction.camera;
|
||||||
if (this._cameras?.has(camera) && this._view) {
|
if (this._cameras?.has(camera) && this._view) {
|
||||||
let targetView =
|
const targetView =
|
||||||
this._getConfig().view.camera_select === 'current'
|
this._getConfig().view.camera_select === 'current'
|
||||||
? this._view.view
|
? this._view.view
|
||||||
: (this._getConfig().view.camera_select as FrigateCardView);
|
: (this._getConfig().view.camera_select as FrigateCardView);
|
||||||
// Fallback to supported views for non-Frigate cameras.
|
|
||||||
if (!this._cameras?.get(camera)?.camera_name) {
|
|
||||||
targetView = View.supportsNonFrigateCameras(targetView)
|
|
||||||
? targetView
|
|
||||||
: 'live';
|
|
||||||
}
|
|
||||||
this._changeView({
|
this._changeView({
|
||||||
view: new View({
|
view: new View({
|
||||||
view: targetView,
|
view: this._cameras?.get(camera)?.camera_name
|
||||||
|
? targetView
|
||||||
|
: // Fallback to supported views for non-Frigate cameras.
|
||||||
|
View.selectBestViewForNonFrigateCameras(targetView),
|
||||||
camera: camera,
|
camera: camera,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
+5
-5
@@ -36,12 +36,12 @@ export class View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether a view is supported on non-Frigate cameras.
|
* Selects the best view for a non-Frigate camera.
|
||||||
* @param view The view to determine support for.
|
* @param view The wanted view.
|
||||||
* @returns Whether the view is supported by non-Frigate cameras.
|
* @returns The closest view supported by the non-Frigate camera.
|
||||||
*/
|
*/
|
||||||
public static supportsNonFrigateCameras(view: FrigateCardView): boolean {
|
public static selectBestViewForNonFrigateCameras(view: FrigateCardView) {
|
||||||
return ['timeline', 'image', 'live'].includes(view);
|
return ['timeline', 'image'].includes(view) ? view : 'live';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user