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
+4
View File
@@ -222,6 +222,10 @@ export class FrigateCardSurround extends LitElement {
slot=${this.timelineConfig.mode} slot=${this.timelineConfig.mode}
.hass=${this.hass} .hass=${this.hass}
.view=${this.view} .view=${this.view}
.itemClickAction=${this.view.isViewerView() ||
this.thumbnailConfig.mode === 'none'
? 'play'
: 'select'}
.cameraIDs=${this._cameraIDsForTimeline} .cameraIDs=${this._cameraIDsForTimeline}
.mini=${true} .mini=${true}
.timelineConfig=${this.timelineConfig} .timelineConfig=${this.timelineConfig}
+17 -2
View File
@@ -38,7 +38,11 @@ import {
TimelineCoreConfig, TimelineCoreConfig,
} from '../types'; } from '../types';
import { stopEventFromActivatingCardWideActions } from '../utils/action'; import { stopEventFromActivatingCardWideActions } from '../utils/action';
import { contentsChanged, isHoverableDevice } from '../utils/basic'; import {
contentsChanged,
dispatchFrigateCardEvent,
isHoverableDevice,
} from '../utils/basic';
import { import {
createQueriesForRecordingsView, createQueriesForRecordingsView,
executeMediaQueryForView, executeMediaQueryForView,
@@ -74,6 +78,8 @@ interface TimelineViewContext {
window?: TimelineWindow; window?: TimelineWindow;
} }
type TimelineItemClickAction = 'play' | 'select';
declare module 'view' { declare module 'view' {
interface ViewContext { interface ViewContext {
timeline?: TimelineViewContext; timeline?: TimelineViewContext;
@@ -187,6 +193,9 @@ export class FrigateCardTimelineCore extends LitElement {
@property({ attribute: false }) @property({ attribute: false })
public cardWideConfig?: CardWideConfig; public cardWideConfig?: CardWideConfig;
@property({ attribute: false })
public itemClickAction?: TimelineItemClickAction;
@state() @state()
protected _locked = false; protected _locked = false;
@@ -503,6 +512,7 @@ export class FrigateCardTimelineCore extends LitElement {
} }
let view: View | null = null; let view: View | null = null;
let drawerAction: 'open' | 'close' = 'close';
if ( if (
this.timelineConfig?.show_recordings && this.timelineConfig?.show_recordings &&
@@ -581,18 +591,23 @@ export class FrigateCardTimelineCore extends LitElement {
} else { } else {
view = this.view.evolve({ view = this.view.evolve({
queryResults: newResults, queryResults: newResults,
view: 'media', view: this.itemClickAction === 'play' ? 'media' : this.view.view,
}); });
} }
if (view?.queryResults?.hasResults()) { if (view?.queryResults?.hasResults()) {
view.mergeInContext({ mediaViewer: { seek: properties.time } }); view.mergeInContext({ mediaViewer: { seek: properties.time } });
} }
if (this.itemClickAction === 'select' && view) {
drawerAction = 'open';
}
} }
if (view) { if (view) {
view.dispatchChangeEvent(this); view.dispatchChangeEvent(this);
} }
dispatchFrigateCardEvent(this, `thumbnails:${drawerAction}`);
this._ignoreClick = false; this._ignoreClick = false;
} }
+3
View File
@@ -51,6 +51,9 @@ export class FrigateCardTimeline extends LitElement {
.thumbnailConfig=${this.timelineConfig.controls.thumbnails} .thumbnailConfig=${this.timelineConfig.controls.thumbnails}
.cameraManager=${this.cameraManager} .cameraManager=${this.cameraManager}
.cardWideConfig=${this.cardWideConfig} .cardWideConfig=${this.cardWideConfig}
.itemClickAction=${this.timelineConfig.controls.thumbnails.mode === 'none'
? 'play'
: 'select'}
> >
</frigate-card-timeline-core> </frigate-card-timeline-core>
</frigate-card-surround>`; </frigate-card-surround>`;