Merge pull request #19 from n8k99/claude/fix-nested-folder-display-015Ytt8mSX9sfytMQC85P4gA

feat(obsidian): pre-warm vault cache on startup for instant browsing
This commit is contained in:
Nathan Eckenrode 2025-11-14 01:23:10 -05:00 committed by GitHub
commit 0ce3e50ac2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,6 +46,12 @@ const ObsidianBridge = (() => {
fmgIdIndex = {};
}
}
// Pre-warm cache if Obsidian is already enabled
if (config.enabled) {
INFO && console.log("Obsidian enabled, pre-warming cache...");
prewarmCache();
}
}
// Save configuration
@ -74,6 +80,10 @@ const ObsidianBridge = (() => {
INFO && console.log("Obsidian connection successful:", data);
config.enabled = true;
saveConfig();
// Pre-warm the cache in the background (don't await)
prewarmCache();
return true;
} catch (error) {
ERROR && console.error("Obsidian connection failed:", error);
@ -83,6 +93,18 @@ const ObsidianBridge = (() => {
}
}
// Pre-warm the vault files cache in the background
async function prewarmCache() {
try {
INFO && console.log("Pre-warming vault file cache...");
await getVaultFiles();
INFO && console.log("Vault file cache pre-warmed successfully!");
} catch (error) {
WARN && console.warn("Failed to pre-warm cache:", error);
// Don't throw - this is just optimization
}
}
// Recursively scan a directory and all subdirectories for .md files
async function scanDirectory(path = "") {
const response = await fetch(`${config.apiUrl}/vault/${encodeURIComponent(path)}`, {