mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
Merge pull request #12 from n8k99/claude/fix-nested-folder-display-015Ytt8mSX9sfytMQC85P4gA
perf(obsidian): optimize folder tree for large vaults
This commit is contained in:
commit
796fcabfc9
2 changed files with 31 additions and 5 deletions
|
|
@ -463,7 +463,7 @@ Add your lore here...
|
|||
return results;
|
||||
}
|
||||
|
||||
// List all notes with basic info
|
||||
// List all notes with basic info (reads frontmatter - slow for large vaults)
|
||||
async function listAllNotes() {
|
||||
const allFiles = await getVaultFiles();
|
||||
const notes = [];
|
||||
|
|
@ -495,6 +495,25 @@ Add your lore here...
|
|||
return notes;
|
||||
}
|
||||
|
||||
// List just file paths (fast - no content reading)
|
||||
async function listAllNotePaths() {
|
||||
const allFiles = await getVaultFiles();
|
||||
|
||||
INFO && console.log(`listAllNotePaths: Found ${allFiles.length} files`);
|
||||
|
||||
// Convert to note objects with just path and name
|
||||
const notes = allFiles.map(filePath => ({
|
||||
path: filePath,
|
||||
name: filePath.split("/").pop().replace(".md", ""),
|
||||
folder: filePath.includes("/") ? filePath.substring(0, filePath.lastIndexOf("/")) : ""
|
||||
}));
|
||||
|
||||
// Sort by path
|
||||
notes.sort((a, b) => a.path.localeCompare(b.path));
|
||||
|
||||
return notes;
|
||||
}
|
||||
|
||||
return {
|
||||
init,
|
||||
config,
|
||||
|
|
@ -509,7 +528,8 @@ Add your lore here...
|
|||
findNoteByFmgId,
|
||||
generateNoteTemplate,
|
||||
searchNotes,
|
||||
listAllNotes
|
||||
listAllNotes,
|
||||
listAllNotePaths
|
||||
};
|
||||
})();
|
||||
|
||||
|
|
|
|||
|
|
@ -300,16 +300,19 @@ async function promptCreateNewNote(elementId, elementType, coordinates) {
|
|||
};
|
||||
|
||||
const showBrowse = async () => {
|
||||
resultsDiv.innerHTML = "<p>Loading all notes...</p>";
|
||||
resultsDiv.innerHTML = "<p>Loading file list...</p>";
|
||||
|
||||
try {
|
||||
const allNotes = await ObsidianBridge.listAllNotes();
|
||||
// Use fast path-only listing (doesn't read file contents)
|
||||
const allNotes = await ObsidianBridge.listAllNotePaths();
|
||||
|
||||
if (allNotes.length === 0) {
|
||||
resultsDiv.innerHTML = "<p style='color: #999;'>No notes in vault</p>";
|
||||
return;
|
||||
}
|
||||
|
||||
INFO && console.log(`Displaying ${allNotes.length} notes in folder tree`);
|
||||
|
||||
// Build folder tree
|
||||
const tree = buildFolderTree(allNotes);
|
||||
resultsDiv.innerHTML = renderFolderTree(tree, allNotes);
|
||||
|
|
@ -321,12 +324,15 @@ async function promptCreateNewNote(elementId, elementType, coordinates) {
|
|||
$("#alert").dialog("close");
|
||||
try {
|
||||
const note = allNotes[index];
|
||||
// Read the file content only when clicked
|
||||
const content = await ObsidianBridge.getNote(note.path);
|
||||
const {frontmatter} = ObsidianBridge.parseFrontmatter(content);
|
||||
|
||||
resolve({
|
||||
path: note.path,
|
||||
name: note.name,
|
||||
content,
|
||||
frontmatter: note.frontmatter
|
||||
frontmatter
|
||||
});
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue