Handle timeline item click corner case.

This commit is contained in:
Dermot Duffy
2023-01-29 19:28:34 -08:00
parent edb7a88266
commit 767d4ee7a0
2 changed files with 30 additions and 31 deletions
+30 -29
View File
@@ -503,37 +503,38 @@ export class FrigateCardTimelineCore extends LitElement {
); );
} else if ( } else if (
properties.item && properties.item &&
properties.what === 'item' && properties.what === 'item'
MediaQueriesClassifier.areRecordingQueries(this.view.query)
) { ) {
const eventView = await this._createViewWithEventMediaQuery( const newResults = this.view.queryResults?.clone()
this._createEventMediaQuerys(), .resetSelectedResult()
{ .selectResultIfFound(
selectedItem: properties.item, (media) => !!this.cameras && media.getID() === properties.item,
targetView: 'media', );
},
); if (!newResults || !newResults.hasSelectedResult()) {
const results = eventView?.queryResults?.getResults(); // This can happen if this is a recording query (with recorded hours)
// Specifically ensure there are _some_ results before dispatching the // and an event is clicked on the timeline, or if the current thumbnails
// view change. // is a filtered view from the media gallery (i.e. any case where the
if (eventView && results && results.length) { // thumbnails may not be match the events on the timeline).
eventView.mergeInContext({ mediaViewer: { seek: properties.time } }); const fullEventView = await this._createViewWithEventMediaQuery(
view = eventView; this._createEventMediaQuerys(),
{
selectedItem: properties.item,
targetView: 'media',
},
);
if (fullEventView?.queryResults?.hasResults()) {
view = fullEventView;
}
} else {
view = this.view.evolve({
queryResults: newResults,
});
}
if (view?.queryResults?.hasResults()) {
view.mergeInContext({ mediaViewer: { seek: properties.time } });
} }
} else if (
properties.item &&
properties.what === 'item' &&
this.view.queryResults?.hasResults() &&
this.view.query
) {
view = this.view.evolve({
queryResults: this.view.queryResults
?.clone()
.resetSelectedResult()
.selectResultIfFound(
(media) => !!this.cameras && media.getID() === properties.item,
),
});
} }
if (view) { if (view) {
-2
View File
@@ -9,8 +9,6 @@
// Hard: // Hard:
// - TODO: Remove FrigateBrowseMediaSource if not necessary (post-gallery). // - TODO: Remove FrigateBrowseMediaSource if not necessary (post-gallery).
// - TODO: Remove browse-media.ts TODOs. // - TODO: Remove browse-media.ts TODOs.
// - TODO: What should the timeline do when an event is clicked on that is not in the queryResults (or if queryResults is empty)?
// - TODO: Should the timeline data source clear events (as it currently does) when the query changes?
import { ViewContext } from 'view'; import { ViewContext } from 'view';
import { import {