Select thumbnail unless in viewer.

This commit is contained in:
Dermot Duffy
2023-04-07 14:38:00 -07:00
parent d25d85eb34
commit ecf954249d
3 changed files with 24 additions and 2 deletions
+17 -2
View File
@@ -38,7 +38,11 @@ import {
TimelineCoreConfig,
} from '../types';
import { stopEventFromActivatingCardWideActions } from '../utils/action';
import { contentsChanged, isHoverableDevice } from '../utils/basic';
import {
contentsChanged,
dispatchFrigateCardEvent,
isHoverableDevice,
} from '../utils/basic';
import {
createQueriesForRecordingsView,
executeMediaQueryForView,
@@ -74,6 +78,8 @@ interface TimelineViewContext {
window?: TimelineWindow;
}
type TimelineItemClickAction = 'play' | 'select';
declare module 'view' {
interface ViewContext {
timeline?: TimelineViewContext;
@@ -187,6 +193,9 @@ export class FrigateCardTimelineCore extends LitElement {
@property({ attribute: false })
public cardWideConfig?: CardWideConfig;
@property({ attribute: false })
public itemClickAction?: TimelineItemClickAction;
@state()
protected _locked = false;
@@ -503,6 +512,7 @@ export class FrigateCardTimelineCore extends LitElement {
}
let view: View | null = null;
let drawerAction: 'open' | 'close' = 'close';
if (
this.timelineConfig?.show_recordings &&
@@ -581,18 +591,23 @@ export class FrigateCardTimelineCore extends LitElement {
} else {
view = this.view.evolve({
queryResults: newResults,
view: 'media',
view: this.itemClickAction === 'play' ? 'media' : this.view.view,
});
}
if (view?.queryResults?.hasResults()) {
view.mergeInContext({ mediaViewer: { seek: properties.time } });
}
if (this.itemClickAction === 'select' && view) {
drawerAction = 'open';
}
}
if (view) {
view.dispatchChangeEvent(this);
}
dispatchFrigateCardEvent(this, `thumbnails:${drawerAction}`);
this._ignoreClick = false;
}