Set timeline to now not to most recent event.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import { EmblaCarouselType } from 'embla-carousel';
|
||||
import { LooseOptionsType } from 'embla-carousel/components/Options';
|
||||
import { CreatePluginType, LoosePluginType } from 'embla-carousel/components/Plugins';
|
||||
import { MediaLoadedInfo } from '../../../../types';
|
||||
import {
|
||||
FrigateCardMediaLoadedEventTarget,
|
||||
dispatchExistingMediaLoadedInfoAsEvent,
|
||||
FrigateMediaLoadedEventTarget,
|
||||
} from '../../../media-info';
|
||||
import { LooseOptionsType } from 'embla-carousel/components/Options';
|
||||
|
||||
declare module 'embla-carousel/components/Plugins' {
|
||||
interface EmblaPluginsType {
|
||||
@@ -17,7 +17,7 @@ type AutoMediaLoadedInfoType = CreatePluginType<LoosePluginType, LooseOptionsTyp
|
||||
|
||||
function AutoMediaLoadedInfo(): AutoMediaLoadedInfoType {
|
||||
let emblaApi: EmblaCarouselType;
|
||||
let slides: (HTMLElement & FrigateMediaLoadedEventTarget)[] = [];
|
||||
let slides: (HTMLElement & FrigateCardMediaLoadedEventTarget)[] = [];
|
||||
const mediaLoadedInfo: MediaLoadedInfo[] = [];
|
||||
|
||||
function init(emblaApiInstance: EmblaCarouselType): void {
|
||||
|
||||
@@ -112,19 +112,19 @@ export function isValidMediaLoadedInfo(info: MediaLoadedInfo): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
// Facilitates correct Typescript typing of media:loaded/unloaded event handlers.
|
||||
export interface FrigateMediaLoadedEventTarget extends EventTarget {
|
||||
// Facilitates correct typing of event handlers.
|
||||
export interface FrigateCardMediaLoadedEventTarget extends EventTarget {
|
||||
addEventListener(
|
||||
event: 'frigate-card:media:loaded',
|
||||
listener: (
|
||||
this: FrigateMediaLoadedEventTarget,
|
||||
this: FrigateCardMediaLoadedEventTarget,
|
||||
ev: CustomEvent<MediaLoadedInfo>,
|
||||
) => void,
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
addEventListener(
|
||||
event: 'frigate-card:media:unloaded',
|
||||
listener: (this: FrigateMediaLoadedEventTarget, ev: CustomEvent) => void,
|
||||
listener: (this: FrigateCardMediaLoadedEventTarget, ev: CustomEvent) => void,
|
||||
options?: AddEventListenerOptions | boolean,
|
||||
): void;
|
||||
addEventListener(
|
||||
@@ -135,14 +135,14 @@ export interface FrigateMediaLoadedEventTarget extends EventTarget {
|
||||
removeEventListener(
|
||||
event: 'frigate-card:media:loaded',
|
||||
listener: (
|
||||
this: FrigateMediaLoadedEventTarget,
|
||||
this: FrigateCardMediaLoadedEventTarget,
|
||||
ev: CustomEvent<MediaLoadedInfo>,
|
||||
) => void,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
removeEventListener(
|
||||
event: 'frigate-card:media:unloaded',
|
||||
listener: (this: FrigateMediaLoadedEventTarget, ev: CustomEvent) => void,
|
||||
listener: (this: FrigateCardMediaLoadedEventTarget, ev: CustomEvent) => void,
|
||||
options?: boolean | EventListenerOptions,
|
||||
): void;
|
||||
removeEventListener(
|
||||
|
||||
@@ -28,6 +28,7 @@ export const changeViewToRecentEventsForCameraAndDependents = async (
|
||||
targetView?: FrigateCardView;
|
||||
select?: ResultSelectType;
|
||||
useCache?: boolean;
|
||||
viewContext?: ViewContext;
|
||||
},
|
||||
): Promise<void> => {
|
||||
const capabilitySearch: CapabilitySearchOptions =
|
||||
@@ -61,6 +62,7 @@ export const changeViewToRecentEventsForCameraAndDependents = async (
|
||||
targetView: options?.targetView,
|
||||
select: options?.select,
|
||||
useCache: options?.useCache,
|
||||
viewContext: options?.viewContext
|
||||
},
|
||||
)
|
||||
)?.dispatchChangeEvent(element);
|
||||
@@ -103,6 +105,7 @@ export const changeViewToRecentRecordingForCameraAndDependents = async (
|
||||
targetView?: FrigateCardView;
|
||||
select?: ResultSelectType;
|
||||
useCache?: boolean;
|
||||
viewContext?: ViewContext;
|
||||
},
|
||||
): Promise<void> => {
|
||||
const cameraIDs = options?.allCameras
|
||||
@@ -131,6 +134,7 @@ export const changeViewToRecentRecordingForCameraAndDependents = async (
|
||||
targetView: options?.targetView,
|
||||
select: options?.select,
|
||||
useCache: options?.useCache,
|
||||
viewContext: options?.viewContext,
|
||||
},
|
||||
)
|
||||
)?.dispatchChangeEvent(element);
|
||||
@@ -159,6 +163,7 @@ export const executeMediaQueryForView = async (
|
||||
targetTime?: Date;
|
||||
select?: ResultSelectType;
|
||||
useCache?: boolean;
|
||||
viewContext?: ViewContext;
|
||||
},
|
||||
): Promise<View | null> => {
|
||||
const queries = query.getQueries();
|
||||
@@ -195,7 +200,8 @@ export const executeMediaQueryForView = async (
|
||||
view: options?.targetView,
|
||||
camera: cameraID,
|
||||
})
|
||||
.mergeInContext(viewerContext);
|
||||
.mergeInContext(options?.viewContext)
|
||||
.mergeInContext(viewerContext)
|
||||
};
|
||||
|
||||
export const executeMediaQueryForViewWithErrorDispatching = async (
|
||||
@@ -209,6 +215,7 @@ export const executeMediaQueryForViewWithErrorDispatching = async (
|
||||
targetTime?: Date;
|
||||
select?: ResultSelectType;
|
||||
useCache?: boolean;
|
||||
viewContext?: ViewContext;
|
||||
},
|
||||
): Promise<View | null> => {
|
||||
try {
|
||||
@@ -218,6 +225,7 @@ export const executeMediaQueryForViewWithErrorDispatching = async (
|
||||
targetTime: options?.targetTime,
|
||||
select: options?.select,
|
||||
useCache: options?.useCache,
|
||||
viewContext: options?.viewContext,
|
||||
});
|
||||
} catch (e: unknown) {
|
||||
errorToConsole(e as Error);
|
||||
|
||||
Reference in New Issue
Block a user