liamcain / obsidian-periodic-notes

Create/manage your daily, weekly, and monthly notes in Obsidian
MIT License
987 stars 67 forks source link

open today opens wrong note in different year #84

Open RonnyPfannschmidt opened 2 years ago

RonnyPfannschmidt commented 2 years ago

im using periodic notes, now ocnfigured for GGGG/[W]WW/E in a Journal folder

when i try t open the note for today (iso date 2022-01-04 i get Journal/2021/12/02 (note named after date not week/weekday) instead of Journal/2022/W01/02 opened

xurizaemon commented 2 years ago

I believe I'm seeing this behaviour, and I suspect it's only noticeable when there are multiple potential matches for the determined filename.

image

This is the structure of my journal entries. When I open today's journal note 2022/06/19, I get the entry from 2015/04/19. Both have filename 19 but different paths.

When we are in openPeriodicNote we have a config (based on the type of note, eg daily) and it has a method on it config.getNote. This will be passed the start of period (a Moment ts for the selected date) and the loaded array of all notes.

https://github.com/liamcain/obsidian-periodic-notes/blob/8f15e5ff0da558cd0f8abe09f3cd61411c486137/src/main.ts#L269-L288

I didn't quite follow yet how TypeScript gets us through the next bit, but config.getNote is a function getDailyNote which uses getDateUID to generate a unique-ish ID for each of the notes discovered and stored in the allNotes array Record (?), which is used to determine the filepath to open. And inspecting this I see that the record contains entries with the ts matching the most recently seen note of that day (eg 01 in the screenshot below), but file details matching the early note entries (2015/08/01).

image (the console.log is something I've inserted into the plugin inside function openPeriodicNote above.)

It looks like the ID generator might be considering only the basename / filename and that having it consider the full path might fix this? Which I think might happen here:

https://github.com/liamcain/obsidian-periodic-notes/blob/c6defe6cebaa4558d1dc99d82d016f277b491b7d/src/cache.ts#L225

... but I can't here map what I see in the source on Github to what I see happen inside Obsidian 😆

xurizaemon commented 2 years ago

Via the Obsidian Discord I learned about the community plugin "BRAT" via which I updated to the 1.0.0-beta3 of Periodic Notes and this issue was resolved! NICE!

Thanks @liamcain