Refactor camera initialization into the camera engines.

This commit is contained in:
Dermot Duffy
2023-02-12 16:10:22 -08:00
parent 587f483f40
commit 06b4cc914c
30 changed files with 1249 additions and 842 deletions
+3 -30
View File
@@ -1,10 +1,5 @@
import { ViewContext } from 'view';
import {
FrigateCardUserSpecifiedView,
FrigateCardView,
FRIGATE_CARD_VIEWS_USER_SPECIFIED,
FRIGATE_CARD_VIEW_DEFAULT,
} from '../types.js';
import { FrigateCardView } from '../types.js';
import { dispatchFrigateCardEvent } from '../utils/basic.js';
import { MediaQueries } from './media-queries';
import { MediaQueriesResults } from './media-queries-results';
@@ -37,28 +32,6 @@ export class View {
this.context = params.context ?? null;
}
/**
* Selects the best view for a non-Frigate camera.
* @param view The wanted view.
* @returns The closest view supported by the non-Frigate camera.
*/
public static selectBestViewForNonFrigateCameras(view: FrigateCardView) {
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;
}
/**
* Detect if a view change represents a major "media change" for the given
* view.
@@ -138,8 +111,8 @@ export class View {
/**
* Determine if current view matches a named view.
*/
public is(name: string): boolean {
return this.view == name;
public is(view: FrigateCardView): boolean {
return this.view == view;
}
/**