Files
spacedrive/interface/index.tsx
Oscar Beaumont d758977d82 Improve Sync + P2P Integration (#1265)
* Big bruh moment

* whoops

* Less stackoverflowy debug

* stuff

* Fix flawed P2P mDNS instance advertisements

* do sync when connecting with peer

* Sync after pairing

* resync_part2 all the time

* Invalidate all the things

* Invalidate whole React Query on sync event

* emit_messages_flag

* emit_messages_flag

* Backend feature flags + "emitSyncEvents" feature

* Patch `confirm` type cause Tauri cringe

* clippy

* idk but plz work

* bruh

* Fix ComLink bug

* remove log

---------

Co-authored-by: Brendan Allan <brendonovich@outlook.com>
2023-08-29 17:54:58 +00:00

68 lines
2.0 KiB
TypeScript

import { Integrations, init } from '@sentry/browser';
import '@fontsource/inter/variable.css';
import { 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';
import { RouterProvider, RouterProviderProps } from 'react-router-dom';
import {
NotificationContextProvider,
P2PContextProvider,
useDebugState,
useLoadBackendFeatureFlags
} from '@sd/client';
import ErrorFallback from './ErrorFallback';
import { P2P } from './app/p2p';
export { ErrorPage } from './ErrorFallback';
export * from './app';
export * from './util/Platform';
export * from './util/keybind';
dayjs.extend(advancedFormat);
dayjs.extend(relativeTime);
dayjs.extend(duration);
init({
dsn: 'https://2fb2450aabb9401b92f379b111402dbc@o1261130.ingest.sentry.io/4504053670412288',
environment: import.meta.env.MODE,
defaultIntegrations: false,
integrations: [new Integrations.HttpContext(), new Integrations.Dedupe()]
});
const 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={{
tabIndex: -1,
className: debugState.reactQueryDevtools === 'invisible' ? 'opacity-0' : ''
}}
/>
) : null;
};
export const SpacedriveInterface = (props: { router: RouterProviderProps['router'] }) => {
useLoadBackendFeatureFlags();
return (
<ErrorBoundary FallbackComponent={ErrorFallback}>
<P2PContextProvider>
<NotificationContextProvider>
<P2P />
<Devtools />
<RouterProvider router={props.router} />
</NotificationContextProvider>
</P2PContextProvider>
</ErrorBoundary>
);
};