Open notuntoward opened 1 month ago
I'm not able to replicate this behaviour. Tried both in my main vault and a testing vault and both seem to work fine. Have you tried this on a new vault without other plugins?
Turns out that this is an interaction with Templater
. Using the new property names you've just added (thanks), my Daily Notes template looks like this:
---
"created date":
"modified date":
excalidraw-plugin: raw
tags:
type: daily
---
**[[<%tp.date.now("YYYY-MM-DD", -1, tp.file.title)%>]]** <--> **[[<%tp.date.now("YYYY-MM-DD", 1, tp.file.title)%>]]**
<% tp.file.cursor() %>
What happens with this when I create a new daily note is that the modified date
and created date
are left blank, like so:
Although the modifed date
is eventually updated when the daily note is edited.
If I remove created date
from the template, that property name is never added, like so:
Is there a workaround for this?
I think it's not working for you because the plugin only treats a file as new if it is empty. I've added an setting to skip this check in the new update. It should work now, but let me know if something doesn't look right.
Thanks for the change. I enabled Allow non-empty file to be treated as a new note
and then ran Open Today's Daily Note
but unfortunately, created date
is still empty, and is never filled it.
Does the issue occur every time? I tried to replicate your issue but could only get it to occur occasionally. Just made a new change with a workaround that seems to fix it for me. Let me know if it works for you.
I just noticed your latest change and tried it. It worked the first time, but after that, only sometimes. I haven't found a pattern to this yet.
That's very strange indeed. For me it works every time now. Are you on Windows by any chance?
Yes, Windows.
Hmm, that might be related. It's a bit difficult for me to test as I'm on a Mac. If you notice a pattern to this bug, please let me know.
I'm on a Mac and I'm experiencing the same issue as above. Running version 1.3.0 and I feel like it did work once (although this may be a false memory) with the settings above, but not after that and not anymore. This is a new vault (I recently started over).
Here are my settings for the plugin...
I have Templater plugin version 2.4.1 and have Trigger Templater on new file creation and Enable folder templates enabled. I've specified default templates for several folders, including the root (/) folder to specifiy a global default template.
Finally I have the core Daily notes plugin enabled, with a default template and location for daily notes configured. The default template has Templater code in it.
Here are my observations:
It feels like some sort of race condition whereby the modification of the newly created file is performed by Front Matter Timestamp and then somehow prevents Templater from also modifying the file and inserting the configured template.
I really hope this gets fixed, because I otherwise love and have needed this plugin, but in it is unusable for me in its current form as it means I have to sacrifice the use of templates (aside from the daily note, which seems to be working for some reason, which I guess is because the core plugin is inserting the template and Templator is still able to parse the code without conflicting with Front Matter Timestamps) since inserting templates after the fact is both cumbersome and doesn't work well when the file has front matter and so do all my templates (it produces weird results).
@kaveh-ahmadian Thanks for the detailed feedback! I think you are right – it seems to have more to do with Templater than Daily Notes. I was able to replicate most of the behaviour you described. Templater seems to need a bit of uninterrupted time to finish processing a template. I've updated the plugin with an option to delay adding timestamps. The default value is 1000 miliseconds, which I think is quite conservative; something as low as 500 works fine for me with Templater, but that probably depends on how complicated your template is. Can you see if it works now?
I tried this on Windows with the new default 1000 milisecond timer, and it worked the first time, then not the next few times, and now every time. Strange. When it works, I see the popup in the screenshot.
@lighthousedino that worked! I tried several different ways (using commands and creating notes manually) and with templates of varying length. I did not adjust the default 1000 ms delay, and while it is noticeable, it isn't a deal breaker and I may not tweak it much if it is working for me.
That said, I get the same message as the screenshot @notuntoward posted above (most if not all times), but it doesn't seem to affect the functionality.
Many thanks for the quick turnaround and fix!
@notuntoward Does the problem still occur even if you increase the delay? If the timestamps got added but not the template, Front Matter Timestamps was probably too early. Do you perhaps have any other plugins apart from Templater that might try to modify new notes?
Strange... I have been experimenting with different delay values but didn't get the 'modified externally' notification. If you notice a pattern, please let me know. I assume it only comes up when creating a new note with a template, and not every time it updates the modified time, right?
I can't exactly figure out a pattern. It seems to happen every time for my daily note, and although I saw it with other templates, I can't seem to replicate it now. I increased the delay to 2000 ms and I still got it when I created a new daily note (only tested by clicking the button in the ribbon).
As I mentioned before, everything is working just fine (template is inserted, Templater code is evaluated, and timestamps are updated), despite the message.
The one thing about my daily note template that may be special, besides the fact that it is probably my largest template, is that it has Meta Bind plugin code, and Tasks plugin code, and Dataview plugin code. I don't think I have any other template as complex yet, but again, I'm just rebuilding my vault from scratch now. I'll continue to keep an eye on it.
After working with the plugin and new note creation using Templater templates for some time, I'm also finding the behavior to be inconsistent like @notuntoward reported earlier. Sometimes it works just fine, even if I get the "modified externally, merging changes" message. Other times it does not work at all. I have to delete the file and recreate it until it does. I can't figure out the cause. Any ideas @lighthousedino ?
That is quite strange. I've been using the plugin for months now and have never encountered the 'modified externally' notification, even with Templater. I think some kind of a race condition is good guess, especially since you mentioned that you have multiple plugin code blocks in the template. Would you mind turning on the debug switch in the plugin settings and see if any errors pop up in the console log (Ctrl + Shift + I on Windows, I think) when it fails to update the timestamps?
This works for me when I run the Obsidian
Create New Note
command. However, it doesn't work with the Obsidian coreDaily Notes
plugin. The plugin's commandOpen Today's Daily Note
creates a new daily note when one doesn't already exist. In this case, nocreated
timestamp property is made.