diff --git a/src/App.tsx b/src/App.tsx index 1f111537..450f0ac5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,6 +22,11 @@ declare global { const DEFAULT_SELECTION: SidebarSelection = { kind: 'filter', filter: 'all' } +const VAULTS = [ + { label: 'Laputa', path: '/Users/luca/Laputa' }, + { label: 'Demo', path: '/Users/luca/Workspace/laputa-app/demo-vault' }, +] + function App() { const [selection, setSelection] = useState(DEFAULT_SELECTION) const [sidebarWidth, setSidebarWidth] = useState(250) @@ -33,10 +38,19 @@ function App() { const [showQuickOpen, setShowQuickOpen] = useState(false) const [showCommitDialog, setShowCommitDialog] = useState(false) const [toastMessage, setToastMessage] = useState(null) + const [vaultPath, setVaultPath] = useState(VAULTS[0].path) - const vault = useVaultLoader() + const vault = useVaultLoader(vaultPath) const notes = useNoteActions(vault.addEntry, vault.updateContent, vault.entries, setToastMessage) + // Reset UI state when vault changes + const handleSwitchVault = useCallback((path: string) => { + setVaultPath(path) + setSelection(DEFAULT_SELECTION) + setGitHistory([]) + notes.closeAllTabs() + }, [notes]) + // Load git history when active tab changes useEffect(() => { if (!notes.activeTabPath) { @@ -131,7 +145,7 @@ function App() { /> - + setToastMessage(null)} /> void +} + +export function StatusBar({ noteCount, vaultPath, vaults, onSwitchVault }: StatusBarProps) { + const [showVaultMenu, setShowVaultMenu] = useState(false) + const menuRef = useRef(null) + + const activeVault = vaults.find((v) => v.path === vaultPath) + + useEffect(() => { + if (!showVaultMenu) return + const handleClick = (e: MouseEvent) => { + if (menuRef.current && !menuRef.current.contains(e.target as Node)) { + setShowVaultMenu(false) + } + } + document.addEventListener('mousedown', handleClick) + return () => document.removeEventListener('mousedown', handleClick) + }, [showVaultMenu]) -export function StatusBar() { return (