spacedrive/packages/interface/src/App.tsx

72 lines
2.2 KiB
TypeScript
Raw Normal View History

import '@fontsource/inter/variable.css';
2022-10-25 01:41:46 +00:00
import { LibraryContextProvider, queryClient, useDebugState } from '@sd/client';
import { Dialogs } from '@sd/ui';
Mobile - File Import (#443) * Fix File modal and Stats * Add disabled and loading state for dialog * Close library drowdown with drawer * catch Rust panics on mobile to prevent UB * Update packages * Move create lib dialog to container * Create library on onboarding * Cleanup metro config & update packages * onClose for Dialog & update library cache * Fix pods, downgrade react-native-svg * Fix lib switching, organization, start import modal * Add device size info * Revert merge + version upgrade/fix * Create Location & Remove placeholder data * Create default modal component * Check if the location already exists * Add media-library + prettier * fix build * Fix Xcode shellScript too * More small fixes * don't export bindings on mobile devices * Explorer store + cleanup * Explorer comp. & add flashlist * [WIP] Files in Locations & new file thumb * clean merge * Fix imports * Fix core on mobile * Add platform context to mobile * Refactor libraryStore * Add thumb url path to platform context * Try fixing app startup * Add zip and video to filethumb * Delete bindings.ts from mobile * Remove heroicons from mobile too * useForwardedRef hook * Media Library permission stuff * Clean import modal * remove valtio-persist from @sd/client * prevent Sentry capturing all events * refactor `@sd/client` to make it better for mobile * fix mobile splashscreen Just trust me bro * fix mobile draw active style * use custom valtioPersist for current library state * remove mobile lockfile It's now in the pnpm workspace so it shared the main one. * finally remove valtio-persist * remove 'mobile' from Platform as it's in interface Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
2022-11-01 13:32:56 +00:00
import {
Dedupe as DedupeIntegration,
HttpContext as HttpContextIntegration,
init
} from '@sentry/browser';
2022-08-12 06:48:49 +00:00
import { QueryClientProvider, defaultContext } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import dayjs from 'dayjs';
import advancedFormat from 'dayjs/plugin/advancedFormat';
import duration from 'dayjs/plugin/duration';
import relativeTime from 'dayjs/plugin/relativeTime';
import { ErrorBoundary } from 'react-error-boundary';
2022-09-12 15:33:16 +00:00
import { MemoryRouter, useNavigate } from 'react-router-dom';
import { AppRouter } from './AppRouter';
import { ErrorFallback } from './ErrorFallback';
import './style.scss';
2022-04-27 01:14:39 +00:00
dayjs.extend(advancedFormat);
dayjs.extend(relativeTime);
dayjs.extend(duration);
init({
Mobile - File Import (#443) * Fix File modal and Stats * Add disabled and loading state for dialog * Close library drowdown with drawer * catch Rust panics on mobile to prevent UB * Update packages * Move create lib dialog to container * Create library on onboarding * Cleanup metro config & update packages * onClose for Dialog & update library cache * Fix pods, downgrade react-native-svg * Fix lib switching, organization, start import modal * Add device size info * Revert merge + version upgrade/fix * Create Location & Remove placeholder data * Create default modal component * Check if the location already exists * Add media-library + prettier * fix build * Fix Xcode shellScript too * More small fixes * don't export bindings on mobile devices * Explorer store + cleanup * Explorer comp. & add flashlist * [WIP] Files in Locations & new file thumb * clean merge * Fix imports * Fix core on mobile * Add platform context to mobile * Refactor libraryStore * Add thumb url path to platform context * Try fixing app startup * Add zip and video to filethumb * Delete bindings.ts from mobile * Remove heroicons from mobile too * useForwardedRef hook * Media Library permission stuff * Clean import modal * remove valtio-persist from @sd/client * prevent Sentry capturing all events * refactor `@sd/client` to make it better for mobile * fix mobile splashscreen Just trust me bro * fix mobile draw active style * use custom valtioPersist for current library state * remove mobile lockfile It's now in the pnpm workspace so it shared the main one. * finally remove valtio-persist * remove 'mobile' from Platform as it's in interface Co-authored-by: Oscar Beaumont <oscar@otbeaumont.me>
2022-11-01 13:32:56 +00:00
dsn: 'https://2fb2450aabb9401b92f379b111402dbc@o1261130.ingest.sentry.io/4504053670412288',
environment: import.meta.env.MODE,
defaultIntegrations: false,
integrations: [new HttpContextIntegration(), new DedupeIntegration()]
});
export default function SpacedriveInterface() {
2022-05-23 07:54:46 +00:00
return (
2022-08-11 09:35:27 +00:00
<ErrorBoundary FallbackComponent={ErrorFallback}>
2022-08-12 06:48:49 +00:00
<QueryClientProvider client={queryClient} contextSharing={true}>
2022-10-25 01:41:46 +00:00
<Devtools />
<MemoryRouter>
2022-09-12 15:33:16 +00:00
<AppRouterWrapper />
</MemoryRouter>
</QueryClientProvider>
</ErrorBoundary>
2022-05-23 07:54:46 +00:00
);
2022-04-17 18:44:34 +00:00
}
2022-09-12 15:33:16 +00:00
2022-10-25 01:41:46 +00:00
function Devtools() {
const debugState = useDebugState();
// The `context={defaultContext}` part is required for this to work on Windows. Why, idk, don't question it
return debugState.reactQueryDevtools !== 'disabled' ? (
<ReactQueryDevtools
position="bottom-right"
context={defaultContext}
toggleButtonProps={{
className: debugState.reactQueryDevtools === 'invisible' ? 'opacity-0' : ''
}}
/>
) : null;
}
2022-09-12 15:33:16 +00:00
// This can't go in `<SpacedriveInterface />` cause it needs the router context but it can't go in `<AppRouter />` because that requires this context
function AppRouterWrapper() {
const navigate = useNavigate();
return (
<LibraryContextProvider onNoLibrary={() => navigate('/onboarding')}>
<AppRouter />
<Dialogs />
2022-09-12 15:33:16 +00:00
</LibraryContextProvider>
);
}