diff --git a/src/App.tsx b/src/App.tsx index 6cb7dee3..ba2010aa 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -330,9 +330,13 @@ function App() { themes: themeManager.themes, activeThemeId: themeManager.activeThemeId, onSwitchTheme: themeManager.switchTheme, onCreateTheme: async () => { - await themeManager.createTheme() - await vault.reloadVault() + const path = await themeManager.createTheme() + const freshEntries = await vault.reloadVault() setSelection({ kind: 'sectionGroup', type: 'Theme' }) + if (path) { + const entry = freshEntries.find(e => e.path === path) + if (entry) notes.handleSelectNote(entry) + } }, onOpenTheme: (themeId: string) => { const entry = vault.entries.find(e => e.path === themeId) diff --git a/src/hooks/useVaultLoader.ts b/src/hooks/useVaultLoader.ts index 1f3da296..3efe955c 100644 --- a/src/hooks/useVaultLoader.ts +++ b/src/hooks/useVaultLoader.ts @@ -172,8 +172,8 @@ export function useVaultLoader(vaultPath: string) { const reloadVault = useCallback( () => loadVaultData(vaultPath) - .then((data) => { setEntries(data.entries); setAllContent((prev) => ({ ...prev, ...data.allContent })); loadModifiedFiles() }) - .catch((err) => console.warn('Vault reload failed:', err)), + .then((data) => { setEntries(data.entries); setAllContent((prev) => ({ ...prev, ...data.allContent })); loadModifiedFiles(); return data.entries }) + .catch((err) => { console.warn('Vault reload failed:', err); return [] as VaultEntry[] }), [vaultPath, loadModifiedFiles], )