Test escalate the loading state

This commit is contained in:
Lim Chee Aun 2024-09-16 13:27:58 +08:00
parent 3ebf7af4c3
commit e5d766a076

View file

@ -442,40 +442,36 @@ function App() {
return <HttpRoute />;
}
if (uiState === 'loading') {
return <Loader id="loader-root" />;
}
return (
<>
<PrimaryRoutes isLoggedIn={isLoggedIn} loading={uiState === 'loading'} />
<PrimaryRoutes isLoggedIn={isLoggedIn} />
<SecondaryRoutes isLoggedIn={isLoggedIn} />
{uiState === 'default' && (
<Routes>
<Route path="/:instance?/s/:id" element={<StatusRoute />} />
</Routes>
)}
{isLoggedIn && <ComposeButton />}
{isLoggedIn && <Shortcuts />}
<Modals />
{isLoggedIn && <NotificationService />}
<BackgroundService isLoggedIn={isLoggedIn} />
{uiState !== 'loading' && <SearchCommand onClose={focusDeck} />}
<SearchCommand onClose={focusDeck} />
<KeyboardShortcutsHelp />
</>
);
}
function Root({ isLoggedIn, loading }) {
function Root({ isLoggedIn }) {
if (isLoggedIn) {
__BENCHMARK.end('time-to-isLoggedIn');
}
return isLoggedIn ? (
<Home />
) : loading ? (
<Loader id="loader-root" />
) : (
<Welcome />
);
return isLoggedIn ? <Home /> : <Welcome />;
}
const PrimaryRoutes = memo(({ isLoggedIn, loading }) => {
const PrimaryRoutes = memo(({ isLoggedIn }) => {
const location = useLocation();
const nonRootLocation = useMemo(() => {
const { pathname } = location;
@ -484,10 +480,7 @@ const PrimaryRoutes = memo(({ isLoggedIn, loading }) => {
return (
<Routes location={nonRootLocation || location}>
<Route
path="/"
element={<Root isLoggedIn={isLoggedIn} loading={loading} />}
/>
<Route path="/" element={<Root isLoggedIn={isLoggedIn} />} />
<Route path="/login" element={<Login />} />
<Route path="/welcome" element={<Welcome />} />
</Routes>