import clsx from 'clsx'; import { Suspense } from 'react'; import { Navigate, Outlet, useLocation } from 'react-router-dom'; import { z } from 'zod'; import { ClientContextProvider, LibraryContextProvider, initPlausible, useClientContext, usePlausiblePageViewMonitor } from '@sd/client'; import { useOperatingSystem, useZodRouteParams } from '~/hooks'; import { usePlatform } from '~/util/Platform'; import { QuickPreview } from '../Explorer/QuickPreview'; import Sidebar from './Sidebar'; import Toasts from './Toasts'; const Layout = () => { const { libraries, library } = useClientContext(); const os = useOperatingSystem(); initPlausible({ platformType: usePlatform().platform === 'tauri' ? 'desktop' : 'web' }); usePlausiblePageViewMonitor({ currentPath: useLocation().pathname }); if (library === null && libraries.data) { const firstLibrary = libraries.data[0]; if (firstLibrary) return ; else return ; } return (
{ // TODO: allow this on some UI text at least / disable default browser context menu e.preventDefault(); return false; }} >
{library ? ( }> ) : (

Please select or create a library in the sidebar.

)}
); }; const PARAMS = z.object({ libraryId: z.string() }); export const Component = () => { const params = useZodRouteParams(PARAMS); return ( ); };