mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-26 17:52:18 +01:00
improve loading screen
This commit is contained in:
parent
7e8e585092
commit
7f446bb201
23
src/app.tsx
23
src/app.tsx
@ -24,25 +24,38 @@ import NotificationsView from "./views/notifications";
|
||||
import { RelaysView } from "./views/relays";
|
||||
import useSubject from "./hooks/use-subject";
|
||||
import { LoginNip05View } from "./views/login/nip05";
|
||||
import { Spinner } from "@chakra-ui/react";
|
||||
import { Button, Flex, Spinner, Text } from "@chakra-ui/react";
|
||||
import { deleteDatabase } from "./services/db";
|
||||
|
||||
const RequireAccount = ({ children }: { children: JSX.Element }) => {
|
||||
const RequireCurrentAccount = ({ children }: { children: JSX.Element }) => {
|
||||
let location = useLocation();
|
||||
const loading = useSubject(accountService.loading);
|
||||
const account = useSubject(accountService.current);
|
||||
|
||||
if (loading) return <Spinner />;
|
||||
if (loading) {
|
||||
return (
|
||||
<Flex alignItems="center" height="100%" gap="4" direction="column">
|
||||
<Flex gap="4" grow="1" alignItems="center">
|
||||
<Spinner />
|
||||
<Text>Loading Accounts</Text>
|
||||
</Flex>
|
||||
<Button variant="link" margin="4" onClick={() => deleteDatabase()}>
|
||||
Stuck loading? clear cache
|
||||
</Button>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
if (!account) return <Navigate to="/login" state={{ from: location.pathname }} replace />;
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
const RootPage = () => (
|
||||
<RequireAccount>
|
||||
<RequireCurrentAccount>
|
||||
<Page>
|
||||
<Outlet />
|
||||
</Page>
|
||||
</RequireAccount>
|
||||
</RequireCurrentAccount>
|
||||
);
|
||||
|
||||
const router = createBrowserRouter([
|
||||
|
Loading…
x
Reference in New Issue
Block a user