Fix clicking on timeline recordings.
This commit is contained in:
+1
-1
@@ -857,7 +857,7 @@ class FrigateCard extends LitElement {
|
|||||||
this._resetMainScroll();
|
this._resetMainScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
View.adoptQueryIfAppropriate(view, this._view);
|
View.adoptFromViewIfAppropriate(view, this._view);
|
||||||
|
|
||||||
this._view = view;
|
this._view = view;
|
||||||
this._generateConditionState();
|
this._generateConditionState();
|
||||||
|
|||||||
@@ -545,11 +545,16 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
this.timelineConfig?.show_recordings &&
|
this.timelineConfig?.show_recordings &&
|
||||||
['background', 'group-label'].includes(properties.what)
|
['background', 'group-label'].includes(properties.what)
|
||||||
) {
|
) {
|
||||||
const query = createQueriesForRecordingsView(
|
const cameraIDs = properties.group
|
||||||
|
? new Set([String(properties.group)])
|
||||||
|
: this._getTimelineCameraIDs();
|
||||||
|
const query = cameraIDs
|
||||||
|
? createQueriesForRecordingsView(
|
||||||
this.cameraManager,
|
this.cameraManager,
|
||||||
this.cardWideConfig,
|
this.cardWideConfig,
|
||||||
new Set([String(properties.group)]),
|
cameraIDs,
|
||||||
);
|
)
|
||||||
|
: null;
|
||||||
if (query) {
|
if (query) {
|
||||||
view = await executeMediaQueryForView(
|
view = await executeMediaQueryForView(
|
||||||
this,
|
this,
|
||||||
|
|||||||
+38
-18
@@ -61,41 +61,61 @@ export class View {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static adoptQueryIfAppropriate(next: View, curr?: View): void {
|
public static adoptFromViewIfAppropriate(next: View, curr?: View): void {
|
||||||
// Special case: If the user is currently using the viewer, and then
|
if (!curr) {
|
||||||
// switches to the gallery we make an attempt to keep the query/queryResults
|
return;
|
||||||
// the same so the gallery can be used to click back and forth to the
|
}
|
||||||
// viewer, and the selected media can be centered in the gallery. See the
|
|
||||||
// matching code in `updated()` in `gallery.ts`. We specifically must ensure
|
// In certain cases it may make sense to adopt parameters from a prior view.
|
||||||
// that the new target media of the gallery (e.g. clips, snapshots or
|
//
|
||||||
|
// * Case #1: If the user is currently using the viewer, and then switches
|
||||||
|
// to the gallery we make an attempt to keep the query/queryResults the
|
||||||
|
// same so the gallery can be used to click back and forth to the viewer,
|
||||||
|
// and the selected media can be centered in the gallery. See the matching
|
||||||
|
// code in `updated()` in `gallery.ts`. We specifically must ensure that
|
||||||
|
// the new target media of the gallery (e.g. clips, snapshots or
|
||||||
// recordings) is equal to the queries that are currently used in the
|
// recordings) is equal to the queries that are currently used in the
|
||||||
// viewer.
|
// viewer. See:
|
||||||
// See: https://github.com/dermotduffy/frigate-hass-card/issues/885
|
// https://github.com/dermotduffy/frigate-hass-card/issues/885
|
||||||
|
//
|
||||||
|
// * Case #2: If the user is looking at media in the `media` view and then
|
||||||
|
// changes camera to the *current* camera (via the menu) it will cause a
|
||||||
|
// new view to issue without a query and just the 'media' view, which
|
||||||
|
// means the viewer cannot know what kind of media to fetch.
|
||||||
|
|
||||||
let currentQueriesView: ClipsOrSnapshots | 'recordings' | null = null;
|
let currentQueriesView: ClipsOrSnapshots | 'recordings' | null = null;
|
||||||
if (MediaQueriesClassifier.areEventQueries(curr?.query)) {
|
if (MediaQueriesClassifier.areEventQueries(curr.query)) {
|
||||||
const queries = curr?.query.getQueries();
|
const queries = curr.query.getQueries();
|
||||||
if (queries?.every((query) => query.hasClip)) {
|
if (queries?.every((query) => query.hasClip)) {
|
||||||
currentQueriesView = 'clips';
|
currentQueriesView = 'clips';
|
||||||
} else if (queries?.every((query) => query.hasSnapshot)) {
|
} else if (queries?.every((query) => query.hasSnapshot)) {
|
||||||
currentQueriesView = 'snapshots';
|
currentQueriesView = 'snapshots';
|
||||||
}
|
}
|
||||||
} else if (MediaQueriesClassifier.areRecordingQueries(curr?.query)) {
|
} else if (MediaQueriesClassifier.areRecordingQueries(curr.query)) {
|
||||||
currentQueriesView = 'recordings';
|
currentQueriesView = 'recordings';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
const hasNoQueryOrResults = !next.query || !next.queryResults;
|
||||||
curr?.isViewerView() &&
|
const switchingToGalleryFromViewer =
|
||||||
next.isGalleryView() &&
|
curr.isViewerView() && next.isGalleryView() && next.view === currentQueriesView;
|
||||||
(!next.query || !next.queryResults) &&
|
const switchingToMediaFromMedia = curr?.is('media') && next.is('media');
|
||||||
next.view === currentQueriesView
|
|
||||||
) {
|
if (hasNoQueryOrResults) {
|
||||||
|
if (switchingToGalleryFromViewer) {
|
||||||
if (curr.query) {
|
if (curr.query) {
|
||||||
next.query = curr.query;
|
next.query = curr.query;
|
||||||
}
|
}
|
||||||
if (curr.queryResults) {
|
if (curr.queryResults) {
|
||||||
next.queryResults = curr.queryResults;
|
next.queryResults = curr.queryResults;
|
||||||
}
|
}
|
||||||
|
} else if (switchingToMediaFromMedia && currentQueriesView) {
|
||||||
|
next.view =
|
||||||
|
currentQueriesView === 'clips'
|
||||||
|
? 'clip'
|
||||||
|
: currentQueriesView === 'snapshots'
|
||||||
|
? 'snapshot'
|
||||||
|
: 'recording';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user