Adding parent and child note lists around the note title in reading mode

I’ve recently converted all my Notion notes to Obsidian, and I’m really happy with this decision.

This unfortunately implies that for each non-leaf folder, I now have a folder note listing its content.

While this is maybe not a good practice with Obsidian, I’m still quite fond of this way of navigating my notes, so directly inside them, without having to use the folder view, at least most of the time.

I’ve therefore implemented a plugin which emulates this Notion feature by automatically adding a parent note breadcrumb over the title, and a child note list below it.

The plugin works, but to this date I still haven’t found any way to make those lists to appear immediately and in all cases when I switch a note to reading mode, or when navigating from note to note, and make them always disappear immediately otherwise.

Most of the time, either the event wasn’t triggered appropriately in all cases, or it was triggered but then the inline-title element could not be found by the selector query, maybe because it wasn’t already rendered.

So after trying many different strategies (MarkdownPostProcessor, etc) and event combinations, I’ve finally resigned myself to remove the parent and child note lists whenever any significant change event was triggered, and use a timer that checks it every quarter of a second if the title should actually be added, so that I could at least make it work and so be able to use it :

Obviously, seeing those lists appear only after a short while is quite unpleasant, so could anybody explain me how I could fix this code to be able to call the clearTitle and updateTitle method directly and in a reliable way without having to use a timer ?