kevboh / longform

A plugin for Obsidian that helps you write and edit novels, screenplays, and other long projects.
Other
672 stars 30 forks source link

[Bug]: Scenes Metadata cache is empty after Obsidian restart #264

Open gasparschott opened 3 months ago

gasparschott commented 3 months ago

Versions Longform version: 2.0.7 Obsidian version: 1.7.0 OS: macOS

I am working to make Longform compatible with my plugin, Continuous Mode. I have added a CM context menu item to allow the user to open Longform projects and scenes in Continuous Mode. To do this I need to access the Longform metadata cache. This worked fine until recently, when I revisited the code for some additional testing. Now there is the following problem:

Describe the bug Calling this.app.metadataCache.getFileCache(longform_index_file).frontmatter.longform.scenes returns an empty array after restarting Obsidian.
Changing the project structure (e.g., moving a scene) updates the metadata to correctly reflect the new structure.
But after another restart, the scenes are again missing from the metadata.
The project itself loads correctly in Obisidan, with all scenes intact and in order.

Screenshots Project structure:
longform-project

Correct metadata:
longform-correct-metadata

Incorrect metadata after restart:
longform-incorrect-metadata-after-restart

gasparschott commented 3 months ago

I see that I can get the list of scenes via workspace.getLeavesOfType('VIEW_TYPE_LONGFORM_EXPLORER')[0].view.explorerView.$$.ctx[1].scenes Edit: But this only returns the list of scenes with indent value and title, whereas the metadatacache info is far more complete and useful.