Fall back to live if the user changes view from recordings.
This commit is contained in:
+3
-2
@@ -1306,10 +1306,11 @@ 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) {
|
||||||
const targetView =
|
const targetView = View.selectBestViewForUserSpecified(
|
||||||
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),
|
||||||
|
);
|
||||||
this._changeView({
|
this._changeView({
|
||||||
view: new View({
|
view: new View({
|
||||||
view: this._cameras?.get(camera)?.frigate.camera_name
|
view: this._cameras?.get(camera)?.frigate.camera_name
|
||||||
|
|||||||
+3
-1
@@ -53,6 +53,8 @@ const FRIGATE_CARD_VIEWS = [
|
|||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
export type FrigateCardView = typeof FRIGATE_CARD_VIEWS[number];
|
export type FrigateCardView = typeof FRIGATE_CARD_VIEWS[number];
|
||||||
|
export type FrigateCardUserSpecifiedView = typeof FRIGATE_CARD_VIEWS_USER_SPECIFIED[number];
|
||||||
|
export const FRIGATE_CARD_VIEW_DEFAULT = 'live' as const;
|
||||||
|
|
||||||
const FRIGATE_MENU_STYLES = ['none', 'hidden', 'overlay', 'hover', 'outside'] as const;
|
const FRIGATE_MENU_STYLES = ['none', 'hidden', 'overlay', 'hover', 'outside'] as const;
|
||||||
const FRIGATE_MENU_POSITIONS = ['left', 'right', 'top', 'bottom'] as const;
|
const FRIGATE_MENU_POSITIONS = ['left', 'right', 'top', 'bottom'] as const;
|
||||||
@@ -526,7 +528,7 @@ export type PictureElements = z.infer<typeof pictureElementsSchema>;
|
|||||||
* View configuration section.
|
* View configuration section.
|
||||||
*/
|
*/
|
||||||
const viewConfigDefault = {
|
const viewConfigDefault = {
|
||||||
default: 'live' as const,
|
default: FRIGATE_CARD_VIEW_DEFAULT,
|
||||||
camera_select: 'current' as const,
|
camera_select: 'current' as const,
|
||||||
timeout_seconds: 300,
|
timeout_seconds: 300,
|
||||||
update_seconds: 0,
|
update_seconds: 0,
|
||||||
|
|||||||
+21
-2
@@ -1,4 +1,10 @@
|
|||||||
import type { FrigateBrowseMediaSource, FrigateCardView } from './types.js';
|
import {
|
||||||
|
FrigateBrowseMediaSource,
|
||||||
|
FrigateCardUserSpecifiedView,
|
||||||
|
FrigateCardView,
|
||||||
|
FRIGATE_CARD_VIEWS_USER_SPECIFIED,
|
||||||
|
FRIGATE_CARD_VIEW_DEFAULT
|
||||||
|
} from './types.js';
|
||||||
import { dispatchFrigateCardEvent } from './utils/basic.js';
|
import { dispatchFrigateCardEvent } from './utils/basic.js';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||||
@@ -41,7 +47,20 @@ export class View {
|
|||||||
* @returns The closest view supported by the non-Frigate camera.
|
* @returns The closest view supported by the non-Frigate camera.
|
||||||
*/
|
*/
|
||||||
public static selectBestViewForNonFrigateCameras(view: FrigateCardView) {
|
public static selectBestViewForNonFrigateCameras(view: FrigateCardView) {
|
||||||
return ['timeline', 'image'].includes(view) ? view : 'live';
|
return ['timeline', 'image'].includes(view) ? view : FRIGATE_CARD_VIEW_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the best view for a user specified view.
|
||||||
|
* @param view The wanted view.
|
||||||
|
* @returns The closest view supported that is user changeable.
|
||||||
|
*/
|
||||||
|
public static selectBestViewForUserSpecified(view: FrigateCardView) {
|
||||||
|
return FRIGATE_CARD_VIEWS_USER_SPECIFIED.includes(
|
||||||
|
view as FrigateCardUserSpecifiedView,
|
||||||
|
)
|
||||||
|
? view
|
||||||
|
: FRIGATE_CARD_VIEW_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user