File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed
Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -128,10 +128,6 @@ class QueryRenderChild extends MarkdownRenderChild {
128128 }
129129
130130 // TODO We need to debounce this.
131- // TODO This very primitive first version redraws all queries for *every* edit to the file containing
132- // this query, regardless of whether the frontmatter has changed or not.
133- // TODO It may even create duplicate refreshes when the query itself is edited
134- // TODO Only do this if the metadata has changed - as this also gets called when the note body is changed.
135131 this . handleMetadataOrFilePathChange ( filePath , fileCache ) ;
136132 } ) ,
137133 ) ;
@@ -148,9 +144,18 @@ class QueryRenderChild extends MarkdownRenderChild {
148144 }
149145
150146 private handleMetadataOrFilePathChange ( filePath : string , fileCache : CachedMetadata | null ) {
147+ const oldTasksFile = this . queryResultsRenderer . tasksFile ;
151148 const newTasksFile = new TasksFile ( filePath , fileCache ?? { } ) ;
152- this . queryResultsRenderer . setTasksFile ( newTasksFile ) ;
153- this . events . triggerRequestCacheUpdate ( this . render . bind ( this ) ) ;
149+
150+ // Has anything changed which might change the query results?
151+ const differentPath = oldTasksFile . path !== newTasksFile . path ;
152+ const differentFrontmatter = ! oldTasksFile . rawFrontmatterIdenticalTo ( newTasksFile ) ;
153+ const queryNeedsReloading = differentPath || differentFrontmatter ;
154+
155+ if ( queryNeedsReloading ) {
156+ this . queryResultsRenderer . setTasksFile ( newTasksFile ) ;
157+ this . events . triggerRequestCacheUpdate ( this . render . bind ( this ) ) ;
158+ }
154159 }
155160
156161 onunload ( ) {
You can’t perform that action at this time.
0 commit comments