eatgrass / obsidian-pomodoro-timer

A pomodoro timer that helps manage your daily focus
MIT License
136 stars 15 forks source link

Implement support for periodic-notes's weekly notes #53

Closed thisismiller closed 6 months ago

thisismiller commented 6 months ago

I do all my planning at the weekly level, and so my daily note is a weekly note.

If one uses the core plugin daily note with a format string of "YYYY-WW" or "gggg-ww", then selecting "Daily note" as the choice for logging will yield a "Cannot create new file" error, because getDailyNote():

  1. looks for daily notes
  2. doesn't find the weekly notes because they're not daily
  3. tries to create a file using the configured daily file name template string
  4. the daily file name template string yields a weekly note filename
  5. gets an error that the weekly file already exists

The solution here is to lean on obsidian-daily-notes-interface a bit more to detect daily vs weekly notes, and then call the corresponding get/create functions. It's a bit unfortunate that there's no getPeriodicNote() in the way that there's a createPeriodicNote() to help remove code duplication.

There's a little bonus here that if a user disables their daily note plugin(s), then the option will stop showing up in the listing, which is a minor existing bug.

Also, this is the first time I've ever written typescript, so literally no idea what proper typescript is. :shrug:

eatgrass commented 6 months ago

@thisismiller Thank you