Use query type instead of view.
This commit is contained in:
@@ -168,7 +168,7 @@ export class FrigateCardSurround extends LitElement {
|
|||||||
if (media) {
|
if (media) {
|
||||||
this.view
|
this.view
|
||||||
?.evolve({
|
?.evolve({
|
||||||
view: this.view.is('recording') ? 'recording' : 'media',
|
view: 'media',
|
||||||
queryResults: ev.detail.queryResults,
|
queryResults: ev.detail.queryResults,
|
||||||
...(media.getCameraID() && { camera: media.getCameraID() }),
|
...(media.getCameraID() && { camera: media.getCameraID() }),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
} else if (
|
} else if (
|
||||||
properties.item &&
|
properties.item &&
|
||||||
properties.what === 'item' &&
|
properties.what === 'item' &&
|
||||||
this.view.is('recording')
|
this.view.query?.areRecordingQueries()
|
||||||
) {
|
) {
|
||||||
viewPromise = (async (): Promise<View | null> => {
|
viewPromise = (async (): Promise<View | null> => {
|
||||||
if (!properties.item || !this.dataManager || !this.hass) {
|
if (!properties.item || !this.dataManager || !this.hass) {
|
||||||
@@ -606,7 +606,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
// Don't show event thumbnails if the user is looking at recordings,
|
// Don't show event thumbnails if the user is looking at recordings,
|
||||||
// as the recording "hours" are the media, not the event
|
// as the recording "hours" are the media, not the event
|
||||||
// clips/snapshots.
|
// clips/snapshots.
|
||||||
if (this._timeline && this.view && !this.view?.is('recording')) {
|
if (this._timeline && this.view && !this.view.query?.areRecordingQueries()) {
|
||||||
(
|
(
|
||||||
await this._createViewWithEventMediaQuery(
|
await this._createViewWithEventMediaQuery(
|
||||||
this._createEventMediaQuerys({ window: prefetchedWindow }),
|
this._createEventMediaQuerys({ window: prefetchedWindow }),
|
||||||
@@ -967,7 +967,7 @@ export class FrigateCardTimelineCore extends LitElement {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!this.mini &&
|
!this.mini &&
|
||||||
!this.view.is('recording') &&
|
!this.view.query?.areRecordingQueries() &&
|
||||||
freshMediaQuery &&
|
freshMediaQuery &&
|
||||||
!this._alreadyHasAcceptableMediaQuery(freshMediaQuery)
|
!this._alreadyHasAcceptableMediaQuery(freshMediaQuery)
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ export class FrigateCardViewer extends LitElement {
|
|||||||
// search for. When the query *is* specified, the view is not required to
|
// search for. When the query *is* specified, the view is not required to
|
||||||
// indicate the media type (e.g. the mixed 'media' view from the
|
// indicate the media type (e.g. the mixed 'media' view from the
|
||||||
// timeline).
|
// timeline).
|
||||||
const mediaType = this.view.getMediaType();
|
const mediaType = this.view.getDefaultMediaType();
|
||||||
if (!browseMediaQueryParameters || !mediaType) {
|
if (!browseMediaQueryParameters || !mediaType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ export class FrigateCardViewer extends LitElement {
|
|||||||
this.cameras,
|
this.cameras,
|
||||||
this.view,
|
this.view,
|
||||||
{
|
{
|
||||||
targetView: mediaType === 'clips' ? 'clip' : 'snapshot',
|
targetView: 'media',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-47
@@ -1,4 +1,4 @@
|
|||||||
// TODO: Do I need getMediaType below?
|
// TODO: Implement gallery.
|
||||||
// TODO: Improve data storage in data-manager to allow fetching by limit not time.
|
// TODO: Improve data storage in data-manager to allow fetching by limit not time.
|
||||||
// TODO: Live should get most recent events regardless of when they were.
|
// TODO: Live should get most recent events regardless of when they were.
|
||||||
// TODO: Refactor thumbnailsControlSchema to all use the shortform for other thumbnail users beyond live.
|
// TODO: Refactor thumbnailsControlSchema to all use the shortform for other thumbnail users beyond live.
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
// TODO: Can _timelineRangeChangedHandler be an async method in timeline-core to improve cleanliness?
|
// TODO: Can _timelineRangeChangedHandler be an async method in timeline-core to improve cleanliness?
|
||||||
// TODO: What should the timeline do when an event is clicked on that is not in the queryResults (or if queryResults is empty)?
|
// 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?
|
// TODO: Should the timeline data source clear events (as it currently does) when the query changes?
|
||||||
// TODO: Implement gallery.
|
|
||||||
|
|
||||||
import isEqual from 'lodash-es/isEqual';
|
import isEqual from 'lodash-es/isEqual';
|
||||||
import clone from 'lodash-es/clone.js';
|
import clone from 'lodash-es/clone.js';
|
||||||
@@ -334,20 +333,6 @@ export class View {
|
|||||||
return ['clips', 'snapshots', 'recordings'].includes(this.view);
|
return ['clips', 'snapshots', 'recordings'].includes(this.view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the viewer view given a gallery view.
|
|
||||||
*/
|
|
||||||
public getViewerViewForGalleryView(): 'clip' | 'snapshot' | 'recording' | null {
|
|
||||||
if (this.is('clips')) {
|
|
||||||
return 'clip';
|
|
||||||
} else if (this.is('snapshots')) {
|
|
||||||
return 'snapshot';
|
|
||||||
} else if (this.is('recordings')) {
|
|
||||||
return 'recording';
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a view is of a piece of media (including the media viewer,
|
* Determine if a view is of a piece of media (including the media viewer,
|
||||||
* live view, image view -- anything that can create a MediaLoadedInfo event).
|
* live view, image view -- anything that can create a MediaLoadedInfo event).
|
||||||
@@ -364,39 +349,21 @@ export class View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if a view is related to a clip or clips.
|
* Get the default media type for this view if available.
|
||||||
*/
|
* @returns Whether the default media is `clips`, `snapshots`, `recordings` or unknown
|
||||||
public isClipRelatedView(): boolean {
|
|
||||||
return ['clip', 'clips'].includes(this.view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a view is related to a snapshot or snapshots.
|
|
||||||
*/
|
|
||||||
public isSnapshotRelatedView(): boolean {
|
|
||||||
return ['snapshot', 'snapshots'].includes(this.view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if a view is related to a recording or recordings.
|
|
||||||
*/
|
|
||||||
public isRecordingRelatedView(): boolean {
|
|
||||||
return ['recording', 'recordings'].includes(this.view);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the media type for this view if available.
|
|
||||||
* @returns Whether the media is `clips`, `snapshots`, `recordings` or unknown
|
|
||||||
* (`null`).
|
* (`null`).
|
||||||
*/
|
*/
|
||||||
public getMediaType(): 'clips' | 'snapshots' | 'recordings' | null {
|
public getDefaultMediaType(): 'clips' | 'snapshots' | 'recordings' | null {
|
||||||
return this.isClipRelatedView()
|
if (['clip', 'clips'].includes(this.view)) {
|
||||||
? 'clips'
|
return 'clips';
|
||||||
: this.isSnapshotRelatedView()
|
}
|
||||||
? 'snapshots'
|
if (['snapshot', 'snapshots'].includes(this.view)) {
|
||||||
: this.isRecordingRelatedView()
|
return 'snapshots';
|
||||||
? 'recordings'
|
}
|
||||||
: null;
|
if (['recording', 'recordings'].includes(this.view)) {
|
||||||
|
return 'recordings';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user