Skip to content

Commit

Permalink
Add workaround to refresh issue of #1752 (#2237)
Browse files Browse the repository at this point in the history
* Add workaround to refresh issue of #1752

Adding a command which can circumvent the issues of #1752, #1759, #2228 (and possibly #1075). This command allows for a full re-run of any query on the active page.

* Forgot the check-format. again
  • Loading branch information
holroy authored Mar 17, 2024
1 parent 75b564b commit 733cadd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Plugin,
PluginSettingTab,
Setting,
WorkspaceLeaf,
} from "obsidian";
import { renderErrorPre } from "ui/render";
import { FullIndex } from "data-index/index";
Expand Down Expand Up @@ -122,6 +123,21 @@ export default class DataviewPlugin extends Plugin {
},
});

interface WorkspaceLeafRebuild extends WorkspaceLeaf {
rebuildView(): void;
}

this.addCommand({
id: "dataview-rebuild-current-view",
name: "Rebuild current view",
callback: () => {
const activeView: MarkdownView | null = this.app.workspace.getActiveViewOfType(MarkdownView);
if (activeView) {
(activeView.leaf as WorkspaceLeafRebuild).rebuildView();
}
},
});

// Run index initialization, which actually traverses the vault to index files.
if (!this.app.workspace.layoutReady) {
this.app.workspace.onLayoutReady(async () => this.index.initialize());
Expand Down

0 comments on commit 733cadd

Please sign in to comment.