Skip to content

Commit a37d9e1

Browse files
committed
refactor: ! Pass TasksEvents in to IncludesSettingsUI.ts
This is to eventually allow edits to the Includes settings to refresh Tasks search results.
1 parent 799f248 commit a37d9e1

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

src/Config/IncludesSettingsUI.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Setting, TextAreaComponent } from 'obsidian';
22
import type TasksPlugin from '../main';
3+
import type { TasksEvents } from '../Obsidian/TasksEvents';
34
import { IncludesSettingsService, type RenamesInProgress } from './IncludesSettingsService';
45
import { type IncludesMap, type Settings, getSettings, updateSettings } from './Settings';
56

@@ -12,15 +13,18 @@ type RefreshViewCallback = () => void;
1213
*/
1314
export class IncludesSettingsUI {
1415
private readonly plugin: TasksPlugin;
16+
// @ts-expect-error: TS6133: events is declared but its value is never read.
17+
private readonly events: TasksEvents;
1518
private readonly includesSettingsService = new IncludesSettingsService();
1619
private readonly nameFields: Map<string, { inputEl: HTMLInputElement; originalKey: string }> = new Map();
1720

1821
/**
1922
* Creates a new instance of IncludesSettingsUI
2023
* @param plugin The Tasks plugin instance
2124
*/
22-
constructor(plugin: TasksPlugin) {
25+
constructor(plugin: TasksPlugin, events: TasksEvents) {
2326
this.plugin = plugin;
27+
this.events = events;
2428
}
2529

2630
/**

src/Config/SettingsTab.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Status } from '../Statuses/Status';
66
import type { StatusCollection } from '../Statuses/StatusCollection';
77
import { createStatusRegistryReport } from '../Statuses/StatusRegistryReport';
88
import { i18n } from '../i18n/i18n';
9+
import type { TasksEvents } from '../Obsidian/TasksEvents';
910
import * as Themes from './Themes';
1011
import {
1112
type HeadingState,
@@ -34,11 +35,11 @@ export class SettingsTab extends PluginSettingTab {
3435
private readonly plugin: TasksPlugin;
3536
private readonly includesSettingsUI;
3637

37-
constructor({ plugin }: { plugin: TasksPlugin }) {
38+
constructor({ plugin, events }: { plugin: TasksPlugin; events: TasksEvents }) {
3839
super(plugin.app, plugin);
3940

4041
this.plugin = plugin;
41-
this.includesSettingsUI = new IncludesSettingsUI(plugin);
42+
this.includesSettingsUI = new IncludesSettingsUI(plugin, events);
4243
}
4344

4445
private static createFragmentWithHTML = (html: string) =>

src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ export default class TasksPlugin extends Plugin {
4141
const { loggingOptions } = getSettings();
4242
logging.configure(loggingOptions);
4343

44-
this.addSettingTab(new SettingsTab({ plugin: this }));
44+
const events = new TasksEvents({ obsidianEvents: this.app.workspace });
45+
46+
this.addSettingTab(new SettingsTab({ plugin: this, events }));
4547

4648
initializeFile({
4749
metadataCache: this.app.metadataCache,
@@ -52,7 +54,6 @@ export default class TasksPlugin extends Plugin {
5254
// Load configured status types.
5355
await this.loadTaskStatuses();
5456

55-
const events = new TasksEvents({ obsidianEvents: this.app.workspace });
5657
this.cache = new Cache({
5758
metadataCache: this.app.metadataCache,
5859
vault: this.app.vault,

0 commit comments

Comments
 (0)