1 import { useState } from 'react';
2 import { BrowserRouter } from 'react-router-dom';
4 import * as bootstrap from '@proton/account/bootstrap';
7 AuthenticationProvider,
11 NotificationsChildren,
14 StandardLoadErrorPage,
15 } from '@proton/components';
16 import useEffectOnce from '@proton/hooks/useEffectOnce';
17 import { ProtonStoreProvider } from '@proton/redux-shared-store';
18 import createApi from '@proton/shared/lib/api/createApi';
19 import { getClientID } from '@proton/shared/lib/apps/helper';
20 import { getNonEmptyErrorMessage } from '@proton/shared/lib/helpers/error';
21 import noop from '@proton/utils/noop';
23 import * as config from './config';
24 import PublicSharedLinkContainer from './containers/PublicSharedLinkContainer';
25 import locales from './locales';
26 import type { DriveStore } from './redux-store/store';
27 import { extendStore, setupStore } from './redux-store/store';
28 import { extraThunkArguments } from './redux-store/thunk';
29 import { userSuccessMetrics } from './utils/metrics/userSuccessMetrics';
30 import { logPerformanceMarker } from './utils/performance';
32 const bootstrapApp = async () => {
33 const authentication = bootstrap.createAuthentication({ initialAuth: false });
34 bootstrap.init({ config, locales, authentication });
36 await userSuccessMetrics.init();
37 await userSuccessMetrics.setVersionHeaders(getClientID(config.APP_NAME), config.APP_VERSION);
39 const store = setupStore();
40 const api = createApi({ config });
41 extendStore({ config, api, authentication });
43 const searchParams = new URLSearchParams(location.search);
44 await bootstrap.publicApp({ app: config.APP_NAME, locales, searchParams, pathLocale: '' });
49 const UrlsApp = () => {
50 const [state, setState] = useState<{ error?: string; store?: DriveStore }>({});
55 const { store } = await bootstrapApp();
57 logPerformanceMarker('drive_performance_clicktobootstrapped_histogram');
58 } catch (error: any) {
60 error: getNonEmptyErrorMessage(error),
67 <ProtonApp config={config}>
70 return <StandardLoadErrorPage errorMessage={state.error} />;
73 return <LoaderPage />;
76 <ProtonStoreProvider store={state.store}>
78 <AuthenticationProvider store={extraThunkArguments.authentication}>
79 <ApiProvider api={extraThunkArguments.api}>
80 <ErrorBoundary big component={<StandardErrorPage big />}>
81 <div className="h-full">
82 <NotificationsChildren />
84 <PublicSharedLinkContainer />
88 </AuthenticationProvider>
90 </ProtonStoreProvider>
97 export default UrlsApp;