mirror of
https://github.com/cheeaun/phanpy.git
synced 2024-12-18 19:31:48 +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 />;
|
return <HttpRoute />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uiState === 'loading') {
|
||||||
|
return <Loader id="loader-root" />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PrimaryRoutes isLoggedIn={isLoggedIn} loading={uiState === 'loading'} />
|
<PrimaryRoutes isLoggedIn={isLoggedIn} />
|
||||||
<SecondaryRoutes isLoggedIn={isLoggedIn} />
|
<SecondaryRoutes isLoggedIn={isLoggedIn} />
|
||||||
{uiState === 'default' && (
|
<Routes>
|
||||||
<Routes>
|
<Route path="/:instance?/s/:id" element={<StatusRoute />} />
|
||||||
<Route path="/:instance?/s/:id" element={<StatusRoute />} />
|
</Routes>
|
||||||
</Routes>
|
|
||||||
)}
|
|
||||||
{isLoggedIn && <ComposeButton />}
|
{isLoggedIn && <ComposeButton />}
|
||||||
{isLoggedIn && <Shortcuts />}
|
{isLoggedIn && <Shortcuts />}
|
||||||
<Modals />
|
<Modals />
|
||||||
{isLoggedIn && <NotificationService />}
|
{isLoggedIn && <NotificationService />}
|
||||||
<BackgroundService isLoggedIn={isLoggedIn} />
|
<BackgroundService isLoggedIn={isLoggedIn} />
|
||||||
{uiState !== 'loading' && <SearchCommand onClose={focusDeck} />}
|
<SearchCommand onClose={focusDeck} />
|
||||||
<KeyboardShortcutsHelp />
|
<KeyboardShortcutsHelp />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Root({ isLoggedIn, loading }) {
|
function Root({ isLoggedIn }) {
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
__BENCHMARK.end('time-to-isLoggedIn');
|
__BENCHMARK.end('time-to-isLoggedIn');
|
||||||
}
|
}
|
||||||
return isLoggedIn ? (
|
return isLoggedIn ? <Home /> : <Welcome />;
|
||||||
<Home />
|
|
||||||
) : loading ? (
|
|
||||||
<Loader id="loader-root" />
|
|
||||||
) : (
|
|
||||||
<Welcome />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const PrimaryRoutes = memo(({ isLoggedIn, loading }) => {
|
const PrimaryRoutes = memo(({ isLoggedIn }) => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const nonRootLocation = useMemo(() => {
|
const nonRootLocation = useMemo(() => {
|
||||||
const { pathname } = location;
|
const { pathname } = location;
|
||||||
|
@ -484,10 +480,7 @@ const PrimaryRoutes = memo(({ isLoggedIn, loading }) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Routes location={nonRootLocation || location}>
|
<Routes location={nonRootLocation || location}>
|
||||||
<Route
|
<Route path="/" element={<Root isLoggedIn={isLoggedIn} />} />
|
||||||
path="/"
|
|
||||||
element={<Root isLoggedIn={isLoggedIn} loading={loading} />}
|
|
||||||
/>
|
|
||||||
<Route path="/login" element={<Login />} />
|
<Route path="/login" element={<Login />} />
|
||||||
<Route path="/welcome" element={<Welcome />} />
|
<Route path="/welcome" element={<Welcome />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
|
|
Loading…
Reference in a new issue