mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
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:
commit
0ce3e50ac2
1 changed files with 22 additions and 0 deletions
|
|
@ -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)}`, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue