From e03f3cf7f82a9a5207390fb0ca28831bb0fea6a0 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Sat, 4 Jun 2022 07:58:45 -0700 Subject: [PATCH] Only check for cache coverage of plausible dates. --- src/components/timeline.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/components/timeline.ts b/src/components/timeline.ts index 67784235..6fa20e30 100644 --- a/src/components/timeline.ts +++ b/src/components/timeline.ts @@ -269,14 +269,15 @@ class TimelineDataManager { end: Date, recordings?: boolean, ): Promise { + // Cannot fetch the future, always clip the end date to now so as to avoid + // checking for coverage that could not possibly exist yet. const now = new Date(); + end = end > now ? now : end; + if (this.hasCoverage(now, start, end)) { return false; } - // Cannot fetch the future. - end = end > now ? now : end; - if (!this._dateStart || start < this._dateStart) { this._dateStart = start; } @@ -1013,12 +1014,7 @@ export class FrigateCardTimelineCore extends LitElement { disabled: false, filterOptions: { whiteList: { - 'frigate-card-thumbnail': [ - 'details', - 'thumbnail', - 'label', - 'event', - ], + 'frigate-card-thumbnail': ['details', 'thumbnail', 'label', 'event'], div: ['title'], span: ['style'], }, @@ -1115,7 +1111,7 @@ export class FrigateCardTimelineCore extends LitElement { // -> New view dispatched (to load thumbnails into outer carousel). // -> New view received ... [loop] const currentContext = this.view.context as TimelineViewContext | null; - if (currentContext?.dateFetch !== this._data.lastFetchDate) { + if (!isEqual(currentContext?.dateFetch, this._data.lastFetchDate)) { const thumbnails = this._generateThumbnails(); this.view ?.evolve({ @@ -1151,7 +1147,7 @@ export class FrigateCardTimelineCore extends LitElement { * Called when an update will occur. * @param changedProps The changed properties */ - protected willUpdate(changedProps: PropertyValues): void { + protected willUpdate(changedProps: PropertyValues): void { if (changedProps.has('timelineConfig')) { if (this.timelineConfig?.controls.thumbnails.size) { this.style.setProperty(