Can anyone provide any insight into how to update a specific tree view item without reloading the entire tree view? More specifically, I’m not quite sure how to update the data in the dataProvider once it becomes part of the TreeView object and then have that change reflected in the sidebar tree view.
For example, the TODO extension uses the following code, which works.
dataProvider = new ToDoDataProvider();
treeView = new TreeView("todo", {
dataProvider: dataProvider,
});
However, I can’t find a way to reload only the changes instead of the entire tree view.
dataProvider.loadData(); // The tree item data changes here.
/*
According to the docs, https://docs.nova.app/api-reference/tree-view/#reloadelement,
it is possible to reload a specific element, which I would assume to mean the array
element (0, 1, 2... etc).
*/
treeView.reload();
Perhaps i’m not understanding how to properly modify what is inside the dataProvider once it becomes part of the TreeView object. Should I be modifying that directly inside the treeView object? Or, is it always pointing to the original dataProvider object? And, how then do I reload only the element that changed? Passing an element treeView.reload(0), for example, seems to have no effect.
treeView.reload(); seem to accept array of elements like . [elementOne, elementTwo] which will reload both of them.
Since you want to reload the element that changed… why not use the following handlers to fetch the element and then passed to the reload function? In theory it should work
I can see how those event listeners return an element from the tree view (a tree item). However, what I really want to do is make a change based on an external event. In this case when a file watch event is triggered and a change to the tags inside that file is detected. If I understand correctly, the Nova TreeView object wouldn’t know what element to provide because that information isn’t coming from the sidebar selection, visibility change, etc.