I stumbled on what seemed like a bug the other day, and I think I've found the right solution.
Problem TL;DR
When a .png file is "yesterday" (as in the case of 2022-05-31 Tuesday.md), there are no todos.
I expected to receive the TODOs from 2022-05-30.md. Instead, the plugin attempts to read from Pasted image 20220531134013.png. (Shown in screenshots below).
I was running the command the rollover TODOs, and getting zero TODOs. After peeking at the developer console, and checking out which file was being chosen as "yesterday" (sorted[1]) was an image file.
This is because I have Obisidian set to store pasted/attached assets next to the note file, instead of in a dedicated assets directory. (One of the default available options).
For example, here's some debug code I added:
... And the result from the developer console:
And the later code that filters with the moment library is very forgiving, and does nothing to filter out those binary PNG files.
Solution
To resolve this, I found that the Obsidian API for vault has a method called getMarkdownFiles. It returns only the Markdown note files from the vault.
When using that method to retrieve files, I see the expected sorted result set, and therefore sorted[1] is guaranteed to be a Markdown file. I receive the expected TODOs, in the expected order. 🎉
Howdy!
I stumbled on what seemed like a bug the other day, and I think I've found the right solution.
Problem TL;DR
When a
.png
file is "yesterday" (as in the case of2022-05-31 Tuesday.md
), there are no todos.I expected to receive the TODOs from
2022-05-30.md
. Instead, the plugin attempts to read fromPasted image 20220531134013.png
. (Shown in screenshots below).I was running the command the rollover TODOs, and getting zero TODOs. After peeking at the developer console, and checking out which file was being chosen as "yesterday" (
sorted[1]
) was an image file.This is because I have Obisidian set to store pasted/attached assets next to the note file, instead of in a dedicated assets directory. (One of the default available options).
For example, here's some debug code I added:
... And the result from the developer console:
And the later code that filters with the
moment
library is very forgiving, and does nothing to filter out those binary PNG files.Solution
To resolve this, I found that the Obsidian API for
vault
has a method calledgetMarkdownFiles
. It returns only the Markdown note files from the vault.When using that method to retrieve files, I see the expected sorted result set, and therefore
sorted[1]
is guaranteed to be a Markdown file. I receive the expected TODOs, in the expected order. 🎉