fix: update side panel on update settings
This commit is contained in:
+34
-10
@@ -5,6 +5,7 @@ import { TASK_FILE_EXTENSION } from "@/model/taskFile";
|
||||
import { FsTaskRepository } from "@/storage/FsTaskRepository";
|
||||
import { NodeFileSystem } from "@/storage/NodeFileSystem";
|
||||
import { VscodeConfigProvider } from "@/storage/VscodeConfigProvider";
|
||||
import { IConfigProvider } from "@/ports";
|
||||
import { registerTaskCodeActions } from "@/ui/taskCodeActions";
|
||||
import { registerTaskCommands } from "@/ui/taskCommands";
|
||||
import { registerTaskDecorations } from "@/ui/taskDecorations";
|
||||
@@ -13,6 +14,24 @@ import { TaskDashboardPanel } from "@/views/taskDashboardPanel";
|
||||
import { TaskKanbanPanel } from "@/views/taskKanbanPanel";
|
||||
import { TaskTreeProvider } from "@/views/taskTreeProvider";
|
||||
|
||||
function createTaskWatchers(
|
||||
config: IConfigProvider,
|
||||
onMutated: () => void,
|
||||
): vscode.Disposable {
|
||||
return vscode.Disposable.from(
|
||||
...resolveTaskLocations(config).map((location) => {
|
||||
const pattern = path
|
||||
.join(location.folderPath, `*${TASK_FILE_EXTENSION}`)
|
||||
.replace(/\\/g, "/");
|
||||
const watcher = vscode.workspace.createFileSystemWatcher(pattern);
|
||||
watcher.onDidCreate(onMutated);
|
||||
watcher.onDidChange(onMutated);
|
||||
watcher.onDidDelete(onMutated);
|
||||
return watcher;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
const fileSystem = new NodeFileSystem();
|
||||
const config = new VscodeConfigProvider();
|
||||
@@ -29,16 +48,21 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
vscode.window.registerTreeDataProvider("xboctukFlow.tasks", tree),
|
||||
);
|
||||
|
||||
for (const location of resolveTaskLocations(config)) {
|
||||
const taskPattern = path
|
||||
.join(location.folderPath, `*${TASK_FILE_EXTENSION}`)
|
||||
.replace(/\\/g, "/");
|
||||
const watcher = vscode.workspace.createFileSystemWatcher(taskPattern);
|
||||
watcher.onDidCreate(onTasksMutated);
|
||||
watcher.onDidChange(onTasksMutated);
|
||||
watcher.onDidDelete(onTasksMutated);
|
||||
context.subscriptions.push(watcher);
|
||||
}
|
||||
let watcherDisposable: vscode.Disposable = createTaskWatchers(
|
||||
config,
|
||||
onTasksMutated,
|
||||
);
|
||||
context.subscriptions.push(watcherDisposable);
|
||||
|
||||
context.subscriptions.push(
|
||||
vscode.workspace.onDidChangeConfiguration((e) => {
|
||||
if (!e.affectsConfiguration("xboctukFlow")) return;
|
||||
watcherDisposable.dispose();
|
||||
watcherDisposable = createTaskWatchers(config, onTasksMutated);
|
||||
context.subscriptions.push(watcherDisposable);
|
||||
tree.refresh();
|
||||
}),
|
||||
);
|
||||
|
||||
const statusBarItem = vscode.window.createStatusBarItem(
|
||||
vscode.StatusBarAlignment.Left,
|
||||
|
||||
@@ -55,7 +55,7 @@ export const TASK_STATUS_META: Record<TaskStatus, TaskStatusMeta> = {
|
||||
},
|
||||
[TaskStatus.UNKNOWN]: {
|
||||
label: "Unknown",
|
||||
defaultHidden: false,
|
||||
defaultHidden: true,
|
||||
icon: "question",
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user