fix: open newly created theme in editor after New Theme command
After createTheme(), the theme file was created and the sidebar navigated to the Theme section, but the note was never opened in the editor. Now captures the returned path and opens it via handleSelectNote. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user