Skip to content

Add metadata change callbacks#115

Merged
gfxholo merged 2 commits intogfxholo:mainfrom
ShadiestGoat:main
Jun 22, 2025
Merged

Add metadata change callbacks#115
gfxholo merged 2 commits intogfxholo:mainfrom
ShadiestGoat:main

Conversation

@ShadiestGoat
Copy link
Copy Markdown
Contributor

@ShadiestGoat ShadiestGoat commented May 6, 2025

Currently, I have a problem that when I edit metadata properties (in frontmatter, if that matters), then I don't get the right update to the icons. Its one change behind, probably a race condition of some kind or other.

This is a fix for that. It adds callbacks to both the vanilla meta store change event & the dataview one. I don't know if the dataview one is necessary, but another one doesn't hurt. I tested with and without dataview enabled & it worked both times so why not?

Also, I noticed that there are only very broad refresh functions, but is there a way to target only the modified files? That might help with performance

kotaindah55 added a commit to kotaindah55/iconic that referenced this pull request May 17, 2025
@gfxholo
Copy link
Copy Markdown
Owner

gfxholo commented Jun 11, 2025

A bug report and its bugfix in one pull request? You're a dream contributor, thank you! 💚 I've tested the changes and they do seem to solve the race condition.

The onModify() method just needs a few changes to gel better with the existing code:

  • Define the method closer to where it's being used. I'd paste it underneath onExternalSettingsChange()
  • Specify a void return type
  • Rename abstractFile back to tAbstractFile (it's named this way on 14 other lines)
  • Rename the method from onModify() to onFileModify() for clarity

I'd also remove the dataview:metadata-change callback completely, because that callback runs whenever Dataview updates its own metadata cache, which can happen thousands of times when you open a large vault. You can watch this happening if you console.log the callback.

@ShadiestGoat
Copy link
Copy Markdown
Contributor Author

Hi, thanks for the review! Those changes sound good, I'll apply them later today.

@gfxholo gfxholo self-assigned this Jun 13, 2025
@gfxholo gfxholo added bug Something isn't working labels Jun 13, 2025
@gfxholo gfxholo modified the milestone: 1.1.2 Jun 13, 2025
@gfxholo gfxholo merged commit 31ce534 into gfxholo:main Jun 22, 2025
@gfxholo
Copy link
Copy Markdown
Owner

gfxholo commented Jun 22, 2025

I went ahead and pushed the changes above to your fork before merging 🚀

Thanks so much for testing and contributing this!

@ShadiestGoat
Copy link
Copy Markdown
Contributor Author

Hey - sorry I didn't do the requested changes, work & life have a habit of being real busy suddenly

@gfxholo
Copy link
Copy Markdown
Owner

gfxholo commented Jun 22, 2025

You're fine! I know all about that struggle too, don't even sweat it 💚

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants