Skip to content

Commit 2584490

Browse files
committed
feat: Redraw Tasks search results whenever Includes settings change
1 parent a37d9e1 commit 2584490

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Config/IncludesSettingsUI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type RefreshViewCallback = () => void;
1313
*/
1414
export class IncludesSettingsUI {
1515
private readonly plugin: TasksPlugin;
16-
// @ts-expect-error: TS6133: events is declared but its value is never read.
1716
private readonly events: TasksEvents;
1817
private readonly includesSettingsService = new IncludesSettingsService();
1918
private readonly nameFields: Map<string, { inputEl: HTMLInputElement; originalKey: string }> = new Map();
@@ -223,5 +222,7 @@ export class IncludesSettingsUI {
223222
if (refreshView) {
224223
refreshView();
225224
}
225+
226+
this.events.triggerReloadOpenSearchResults();
226227
}
227228
}

src/Renderer/QueryRenderer.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class QueryRenderChild extends MarkdownRenderChild {
9090
private readonly events: TasksEvents;
9191

9292
private renderEventRef: EventRef | undefined;
93+
private reloadSearchResultsEventRef: EventRef | undefined;
9394
private queryReloadTimeout: NodeJS.Timeout | undefined;
9495

9596
private isCacheChangedSinceLastRedraw = false;
@@ -134,8 +135,10 @@ class QueryRenderChild extends MarkdownRenderChild {
134135

135136
// Process the current cache state:
136137
this.events.triggerRequestCacheUpdate(this.render.bind(this));
137-
// Listen to future cache changes:
138+
139+
// Listen to future changes:
138140
this.renderEventRef = this.events.onCacheUpdate(this.render.bind(this));
141+
this.reloadSearchResultsEventRef = this.events.onReloadOpenSearchResults(this.rereadQueryFromFile.bind(this));
139142

140143
this.reloadQueryAtMidnight();
141144

@@ -221,6 +224,10 @@ class QueryRenderChild extends MarkdownRenderChild {
221224
this.events.off(this.renderEventRef);
222225
}
223226

227+
if (this.reloadSearchResultsEventRef !== undefined) {
228+
this.events.off(this.reloadSearchResultsEventRef);
229+
}
230+
224231
if (this.queryReloadTimeout !== undefined) {
225232
clearTimeout(this.queryReloadTimeout);
226233
}
@@ -304,6 +311,13 @@ class QueryRenderChild extends MarkdownRenderChild {
304311

305312
this.containerEl.firstChild?.replaceWith(content);
306313
}
314+
315+
private rereadQueryFromFile() {
316+
this.queryResultsRenderer.rereadQueryFromFile();
317+
this.isCacheChangedSinceLastRedraw = true;
318+
// TODO Debounce this rendering
319+
this.render({ tasks: this.plugin.getTasks(), state: this.plugin.getState() });
320+
}
307321
}
308322

309323
function createEditTaskPencilClickHandler(app: App): EditButtonClickHandler {

0 commit comments

Comments
 (0)