Skip to content

Commit

Permalink
Fix loading issue of Document when viewing shared documents by moving…
Browse files Browse the repository at this point in the history
… `useSettingsQuery` Hook globally
  • Loading branch information
devleejb authored Jul 13, 2024
1 parent 32e5355 commit e1cebe0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 7 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { QueryCache, QueryClient, QueryClientProvider } from "@tanstack/react-qu
import AuthProvider from "./providers/AuthProvider";
import { useErrorHandler } from "./hooks/useErrorHandler";
import * as Sentry from "@sentry/react";
import { useGetSettingsQuery } from "./hooks/api/settings";

if (import.meta.env.PROD) {
Sentry.init({
Expand Down Expand Up @@ -49,6 +50,11 @@ const router = createBrowserRouter(routes);

axios.defaults.baseURL = import.meta.env.VITE_API_ADDR;

function SettingLoader() {
useGetSettingsQuery();
return null;
}

function App() {
const config = useSelector(selectConfig);
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
Expand Down Expand Up @@ -85,6 +91,7 @@ function App() {
<AuthProvider>
<ThemeProvider theme={theme}>
<CssBaseline />
<SettingLoader />
<Box minHeight="100vh">
<RouterProvider router={router} />
</Box>
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/components/common/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { ReactNode, useContext } from "react";
import { useLocation, Navigate } from "react-router-dom";
import { AuthContext } from "../../contexts/AuthContext";
import { Backdrop, CircularProgress } from "@mui/material";
import { useGetSettingsQuery } from "../../hooks/api/settings";

interface PrivateRouteProps {
children?: ReactNode;
Expand All @@ -13,8 +12,6 @@ const PrivateRoute = (props: PrivateRouteProps) => {
const { isLoggedIn, isLoading } = useContext(AuthContext);
const location = useLocation();

useGetSettingsQuery();

if (isLoading) {
return (
<Backdrop open>
Expand Down

0 comments on commit e1cebe0

Please sign in to comment.