Skip to content

Commit

Permalink
Add lazy loading for UserPresenceList
Browse files Browse the repository at this point in the history
  • Loading branch information
choidabom committed Aug 24, 2024
1 parent 792f76c commit 62fac72
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions frontend/src/components/headers/DocumentHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import VerticalSplitIcon from "@mui/icons-material/VerticalSplit";
import VisibilityIcon from "@mui/icons-material/Visibility";
import {
AppBar,
CircularProgress,
IconButton,
Paper,
Stack,
Expand All @@ -12,7 +13,7 @@ import {
Toolbar,
Tooltip,
} from "@mui/material";
import { useEffect } from "react";
import { lazy, Suspense, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { useUserPresence } from "../../hooks/useUserPresence";
Expand All @@ -21,8 +22,8 @@ import { selectWorkspace } from "../../store/workspaceSlice";
import DownloadMenu from "../common/DownloadMenu";
import ShareButton from "../common/ShareButton";
import ThemeButton from "../common/ThemeButton";
import UserPresenceList from "./UserPresenceList";

const UserPresenceList = lazy(() => import("./UserPresenceList"));
function DocumentHeader() {
const dispatch = useDispatch();
const navigate = useNavigate();
Expand Down Expand Up @@ -86,7 +87,9 @@ function DocumentHeader() {
<DownloadMenu />
</Stack>
<Stack direction="row" alignItems="center" gap={1}>
<UserPresenceList presenceList={presenceList} />
<Suspense fallback={<CircularProgress size={24} />}>
<UserPresenceList presenceList={presenceList} />
</Suspense>
{!editorState.shareRole && <ShareButton />}
<ThemeButton />
</Stack>
Expand Down

0 comments on commit 62fac72

Please sign in to comment.