Reset the query on grid change in a smarter way.

This commit is contained in:
Dermot Duffy
2023-08-11 19:49:42 -07:00
parent fe2adb5b89
commit cc77caa96d
10 changed files with 116 additions and 108 deletions
+11 -8
View File
@@ -149,7 +149,6 @@ export class FrigateCardViewer extends LitElement {
{
allCameras: this.view.isGrid(),
targetView: 'recording',
select: 'latest',
},
);
} else {
@@ -163,7 +162,6 @@ export class FrigateCardViewer extends LitElement {
allCameras: this.view.isGrid(),
targetView: 'media',
mediaType: mediaType,
select: 'latest',
},
);
}
@@ -648,18 +646,23 @@ export class FrigateCardViewerGrid extends LitElement {
}
protected willUpdate(changedProps: PropertyValues): void {
if (
changedProps.has('view') &&
this.view?.isGrid() &&
this.view?.hasMultipleDisplayModes()
) {
if (changedProps.has('view') && this._needsGrid()) {
import('./media-grid.js');
}
}
protected _needsGrid(): boolean {
const cameraIDs = this.view?.queryResults?.getCameraIDs();
return (
!!this.view?.isGrid() &&
!!this.view?.supportsMultipleDisplayModes() &&
(cameraIDs?.size ?? 0) > 1
);
}
protected render(): TemplateResult {
const cameraIDs = this.view?.queryResults?.getCameraIDs();
if (!cameraIDs || !this.view?.isGrid() || !this.view?.hasMultipleDisplayModes()) {
if (!cameraIDs || !this._needsGrid()) {
return this._renderCarousel();
}