Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔦 reduce flashing #399

Merged
merged 3 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions frontend/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { ModalHolder } from './components/modal';
import { Helmet } from 'react-helmet';
import { registerCopyHandler } from './utils/copy_text';
import { useAuthData } from './utils/auth';
import { LoadingPage } from './pages/loading';
import { PagePage } from './pages/page';
import { AboutPage } from './pages/about';
import { useGetConfig } from './api/config';
Expand All @@ -24,7 +23,7 @@ export function AuthenticatedRoute<T extends DefaultParams = DefaultParams>({
const { isLoggedIn, hasShareToken, isLoading } = useAuthData();
const isAuthenticated = isLoggedIn || hasShareToken;
if (isLoading) {
return <Route component={LoadingPage} />;
return null;
}
if (!isAuthenticated) {
navigate('/login');
Expand All @@ -39,7 +38,7 @@ export function LoggedInRoute<T extends DefaultParams = DefaultParams>({
const [_, navigate] = useLocation();
const { isLoggedIn, isLoading } = useAuthData();
if (isLoading) {
return <Route component={LoadingPage} />;
return null;
}
if (!isLoggedIn) {
navigate('/login');
Expand All @@ -54,18 +53,19 @@ export function LoggedInRedirectRoute<T extends DefaultParams = DefaultParams>({
const [_, navigate] = useLocation();
const { isLoggedIn, isLoading } = useAuthData();
const { data: config, isLoading: configLoading } = useGetConfig({});
if (isLoading) {
return <Route component={LoadingPage} />;
}
if (!isLoggedIn && !configLoading && config !== undefined) {
if (!isLoggedIn && !isLoading && !configLoading && config !== undefined) {
if (config.logged_out_redirect_url) {
window.location.replace(config.logged_out_redirect_url);
} else {
navigate('/login');
}
}

if (isLoggedIn) {
return <Route {...props} />;
} else {
return null;
}
return <Route {...props} />;
}

export function App() {
Expand Down
12 changes: 0 additions & 12 deletions frontend/src/pages/loading.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions frontend/src/pages/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AppCenter } from '../components/app';
import ReactMarkdown from 'react-markdown';
import { getPage, useGetPage } from '../api/pages';
import { PageNotFoundPage } from './page_not_found';
import { LoadingPage } from './loading';

export function PagePage({ params: { pageId } }: RouteComponentProps<{ pageId: string }>) {
const { data, error } = useGetPage({ page_id: pageId });
Expand All @@ -14,7 +13,7 @@ export function PagePage({ params: { pageId } }: RouteComponentProps<{ pageId: s
}
}
if (!data) {
return <LoadingPage />;
return null;
}
return (
<AppCenter>
Expand Down