blacksmithgu / obsidian-dataview

A data index and query language over Markdown files, for https://obsidian.md/.
https://blacksmithgu.github.io/obsidian-dataview/
MIT License
6.9k stars 407 forks source link

Ability to Disable `Automatic view refreshing` for Select Queries #2396

Open itsonlyjames opened 2 months ago

itsonlyjames commented 2 months ago

I have a dataviewjs query which renders a TikZ diagram from a single source file. With Automatic view refreshing enabled, it constantly flickers while editing the notes content and disrupts the experience (constantly jumping around at the designated interval, default 2500ms). However, disabling the setting globally then removes the benefits of my markdown tables updating automatically. For example, if I have my weekly note next to my daily note, and update my frontmatter in my daily note, I have to then manually Rebuild current view on the weekly note, or close/open it.

Describe the solution you'd like

Within a dataviewjs codeblock, it would be nice to disable refreshing for that particular block, potentially with a comment—similar to how typescript has @ts-ignore. For example:

```dataviewjs
@dataview-js-disable-refresh
await dv.view("3. Resources/Scripts/Time-Traveller's Log", 0)

With this comment, it would simply skip over the refreshOperation func or the maybeRefresh. I don't have enough knowledge on the codebase as yet to provide a PR, but am actively investigating some solutions for a temporary fix, however I look to you for a more appropriate solution.

Describe alternatives you've considered

I have disabled the setting so as to remove the flickering issue, however I also have lost the automatic updating of other dataview components. For my use case, it would suffice to only listen to frontmatter changes (rather than whole document changes), thus editing content would not cause a flicker, but altering my frontmatter would still propagate updates to other views causing refreshing. This is an edge-case however, I imagine other users have metadata outside of just frontmatter. Maybe a setting could be instantiated: "Automatic view refreshing: only listen to frontmatter changes"? However, I think providing users the ability to control refreshing per codeblock might be a more appropriate solution.