mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-18 09:51:57 +03:00
Test escalate the loading state
This commit is contained in:
parent
3ebf7af4c3
commit
e5d766a076
1 changed files with 13 additions and 20 deletions
33
src/app.jsx
33
src/app.jsx
|
@ -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>
|
||||
)}
|
||||
<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>
|
||||
|
|
Loading…
Reference in a new issue