Fall back to live if the user changes view from recordings.

This commit is contained in:
Dermot Duffy
2022-06-12 09:13:58 -07:00
parent 8cd83087e1
commit 4e53ad16eb
3 changed files with 27 additions and 5 deletions
+21 -2
View File
@@ -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';
// 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.
*/
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;
}
/**