beaussan / update-time-on-edit-obsidian

MIT License
165 stars 15 forks source link

Race condition between typing and time update #87

Open Smitty010 opened 3 weeks ago

Smitty010 commented 3 weeks ago

I know that there is a time you can set between updates. However, there needs to be a time before the first update time is written (they could be the same time).

Here's what can happen.

  1. I create a note via ctrl-n
  2. I've automated this process so that a template is applied to the note immediately after creation.

It's not uncommon to see a note with:

---
Updated: ....
Created: ...
---
---
prop1: ...
prop2: ...
---
...

I'm also a relatively fast typer. I will bring up a note and start to type. It appears your code comes in and tries to update the note with the update time almost immediately. However, I'm still in the middle of typing. I've seen things I wrote partially or completely wiped out.

When I see this happen, I see the notification that the has been modified (also, I should be able to turn that off as that delays things and may be part of the problem; I'm willing to trust that you changed the "updated" date/time).