Avoid dispatching range changed events if there's nothing to be gained.

This commit is contained in:
Dermot Duffy
2023-01-30 20:21:12 -08:00
parent 93e8a8e71b
commit f9f2a494c6
4 changed files with 47 additions and 7 deletions
+14 -5
View File
@@ -595,13 +595,22 @@ export class FrigateCardTimelineCore extends LitElement {
this.view &&
!MediaQueriesClassifier.areRecordingQueries(this.view.query)
) {
(
await this._createViewWithEventMediaQuery(
const newView = await this._createViewWithEventMediaQuery(
this._createEventMediaQuerys({ window: this._timeline.getWindow() }),
)
)
?.mergeInContext(this._setWindowInContext())
?.dispatchChangeEvent(this);
// Specifically avoid dispatching new results on range change unless there
// is something to be gained by doing so. Example usecase: On initial view
// load in mini timeline mode, the first 50 events are fetched -- the
// first drag of the timeline should not dispatch new results unless
// something is actually useful (as otherwise it creates a visible
// 'flicker' for the user as the viewer reloads all the media).
const newResults = newView?.queryResults;
if (newView && newResults && !this.view.queryResults?.isSupersetOf(newResults)) {
newView
?.mergeInContext(this._setWindowInContext())
?.dispatchChangeEvent(this);
}
}
}