Skip to content

Commit 3851f86

Browse files
Merge pull request #334 from boostcampwm-2024/bug-fe-#333
초기 렌더링 문제 해결
2 parents a67ea1f + 8b68af7 commit 3851f86

File tree

6 files changed

+68
-78
lines changed

6 files changed

+68
-78
lines changed

apps/frontend/src/app/App.tsx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
1-
import { useEffect } from "react";
2-
import * as Y from "yjs";
3-
41
import { useSyncedUsers } from "@/entities/user";
52
import { SideWrapper } from "@/shared/ui";
63
import { CanvasView } from "@/widgets/CanvasView";
74
import { EditorView } from "@/widgets/EditorView";
85
import { PageSideBarView } from "@/widgets/PageSideBarView";
96
import { CanvasToolsView } from "@/widgets/CanvasToolsView";
10-
import { useWorkspace } from "@/shared/lib/useWorkspace";
11-
import useYDocStore from "@/shared/model/ydocStore";
127
import { useGetUser } from "@/features/auth/model/useAuth";
138

149
function App() {
1510
useSyncedUsers();
1611
useGetUser();
1712

18-
const workspace = useWorkspace();
19-
const { setYDoc } = useYDocStore();
20-
21-
useEffect(() => {
22-
const doc = new Y.Doc({ guid: workspace });
23-
setYDoc(doc);
24-
}, [workspace, setYDoc]);
25-
2613
return (
2714
<div className="fixed inset-0 bg-white">
2815
<SideWrapper side="right" className="z-50">

apps/frontend/src/entities/page/api/pageApi.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export const getPage = async (id: number) => {
1414
return res.data.page;
1515
};
1616

17-
export const getPages = async () => {
18-
const url = "/api/page";
17+
// TODO: 임시
18+
export const getPages = async (workspaceId: string) => {
19+
const url = `/api/page/workspace/${workspaceId}`;
1920

2021
const res = await Get<GetPagesResponse>(url);
2122
return res.data.pages;

apps/frontend/src/features/canvas/model/useCanvas.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ export const useCanvas = () => {
3434
const { zoom } = useViewport();
3535
const [nodes, setNodes, onNodesChange] = useNodesState<Node>([]);
3636
const [edges, setEdges, onEdgesChange] = useEdgesState<Edge>([]);
37-
const { pages } = usePages();
37+
const workspace = useWorkspace();
38+
const { pages } = usePages(workspace);
39+
3840
const queryClient = useQueryClient();
3941
const { ydoc } = useYDocStore();
4042
const { getIntersectingNodes } = useReactFlow();
4143

42-
const workspace = useWorkspace();
43-
4444
const { cursors, handleMouseMove, handleNodeDrag, handleMouseLeave } =
4545
useCollaborativeCursors({
4646
ydoc,

apps/frontend/src/features/pageSidebar/api/usePages.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ export const useDeletePage = () => {
4949
});
5050
};
5151

52-
export const usePages = () => {
52+
export const usePages = (workspaceId: string) => {
5353
const { data: pages, isError } = useQuery({
54-
queryKey: ["pages"],
55-
queryFn: getPages,
54+
queryKey: ["pages", workspaceId],
55+
queryFn: workspaceId ? () => getPages(workspaceId) : skipToken,
5656
});
5757

5858
return { pages, isError };

apps/frontend/src/features/pageSidebar/ui/Tools/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { useCreatePage, usePages } from "@/features/pageSidebar/api/usePages";
66
import { usePageStore } from "../../model/pageStore";
77
import useYDocStore from "@/shared/model/ydocStore";
88
import { initializeYText } from "@/shared/model";
9+
import { useWorkspace } from "@/shared/lib/useWorkspace";
910

1011
export function Tools() {
1112
const { setCurrentPage } = usePageStore();
12-
const { pages } = usePages();
13+
const workspace = useWorkspace();
14+
const { pages } = usePages(workspace);
1315
const createMutation = useCreatePage();
1416
const { ydoc } = useYDocStore();
1517

apps/frontend/src/routeTree.gen.ts

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -10,104 +10,104 @@
1010

1111
// Import Routes
1212

13-
import { Route as rootRoute } from "./routes/__root";
14-
import { Route as IndexImport } from "./routes/index";
15-
import { Route as JoinIndexImport } from "./routes/join/index";
16-
import { Route as WorkspaceWorkspaceIdImport } from "./routes/joinworkspace/$workspaceId";
13+
import { Route as rootRoute } from './routes/__root'
14+
import { Route as IndexImport } from './routes/index'
15+
import { Route as JoinIndexImport } from './routes/join/index'
16+
import { Route as WorkspaceWorkspaceIdImport } from './routes/workspace/$workspaceId'
1717

1818
// Create/Update Routes
1919

2020
const IndexRoute = IndexImport.update({
21-
id: "/",
22-
path: "/",
21+
id: '/',
22+
path: '/',
2323
getParentRoute: () => rootRoute,
24-
} as any);
24+
} as any)
2525

2626
const JoinIndexRoute = JoinIndexImport.update({
27-
id: "/join/",
28-
path: "/join/",
27+
id: '/join/',
28+
path: '/join/',
2929
getParentRoute: () => rootRoute,
30-
} as any);
30+
} as any)
3131

3232
const WorkspaceWorkspaceIdRoute = WorkspaceWorkspaceIdImport.update({
33-
id: "/workspace/$workspaceId",
34-
path: "/workspace/$workspaceId",
33+
id: '/workspace/$workspaceId',
34+
path: '/workspace/$workspaceId',
3535
getParentRoute: () => rootRoute,
36-
} as any);
36+
} as any)
3737

3838
// Populate the FileRoutesByPath interface
3939

40-
declare module "@tanstack/react-router" {
40+
declare module '@tanstack/react-router' {
4141
interface FileRoutesByPath {
42-
"/": {
43-
id: "/";
44-
path: "/";
45-
fullPath: "/";
46-
preLoaderRoute: typeof IndexImport;
47-
parentRoute: typeof rootRoute;
48-
};
49-
"/workspace/$workspaceId": {
50-
id: "/workspace/$workspaceId";
51-
path: "/workspace/$workspaceId";
52-
fullPath: "/workspace/$workspaceId";
53-
preLoaderRoute: typeof WorkspaceWorkspaceIdImport;
54-
parentRoute: typeof rootRoute;
55-
};
56-
"/join/": {
57-
id: "/join/";
58-
path: "/join";
59-
fullPath: "/join";
60-
preLoaderRoute: typeof JoinIndexImport;
61-
parentRoute: typeof rootRoute;
62-
};
42+
'/': {
43+
id: '/'
44+
path: '/'
45+
fullPath: '/'
46+
preLoaderRoute: typeof IndexImport
47+
parentRoute: typeof rootRoute
48+
}
49+
'/workspace/$workspaceId': {
50+
id: '/workspace/$workspaceId'
51+
path: '/workspace/$workspaceId'
52+
fullPath: '/workspace/$workspaceId'
53+
preLoaderRoute: typeof WorkspaceWorkspaceIdImport
54+
parentRoute: typeof rootRoute
55+
}
56+
'/join/': {
57+
id: '/join/'
58+
path: '/join'
59+
fullPath: '/join'
60+
preLoaderRoute: typeof JoinIndexImport
61+
parentRoute: typeof rootRoute
62+
}
6363
}
6464
}
6565

6666
// Create and export the route tree
6767

6868
export interface FileRoutesByFullPath {
69-
"/": typeof IndexRoute;
70-
"/workspace/$workspaceId": typeof WorkspaceWorkspaceIdRoute;
71-
"/join": typeof JoinIndexRoute;
69+
'/': typeof IndexRoute
70+
'/workspace/$workspaceId': typeof WorkspaceWorkspaceIdRoute
71+
'/join': typeof JoinIndexRoute
7272
}
7373

7474
export interface FileRoutesByTo {
75-
"/": typeof IndexRoute;
76-
"/workspace/$workspaceId": typeof WorkspaceWorkspaceIdRoute;
77-
"/join": typeof JoinIndexRoute;
75+
'/': typeof IndexRoute
76+
'/workspace/$workspaceId': typeof WorkspaceWorkspaceIdRoute
77+
'/join': typeof JoinIndexRoute
7878
}
7979

8080
export interface FileRoutesById {
81-
__root__: typeof rootRoute;
82-
"/": typeof IndexRoute;
83-
"/workspace/$workspaceId": typeof WorkspaceWorkspaceIdRoute;
84-
"/join/": typeof JoinIndexRoute;
81+
__root__: typeof rootRoute
82+
'/': typeof IndexRoute
83+
'/workspace/$workspaceId': typeof WorkspaceWorkspaceIdRoute
84+
'/join/': typeof JoinIndexRoute
8585
}
8686

8787
export interface FileRouteTypes {
88-
fileRoutesByFullPath: FileRoutesByFullPath;
89-
fullPaths: "/" | "/workspace/$workspaceId" | "/join";
90-
fileRoutesByTo: FileRoutesByTo;
91-
to: "/" | "/workspace/$workspaceId" | "/join";
92-
id: "__root__" | "/" | "/workspace/$workspaceId" | "/join/";
93-
fileRoutesById: FileRoutesById;
88+
fileRoutesByFullPath: FileRoutesByFullPath
89+
fullPaths: '/' | '/workspace/$workspaceId' | '/join'
90+
fileRoutesByTo: FileRoutesByTo
91+
to: '/' | '/workspace/$workspaceId' | '/join'
92+
id: '__root__' | '/' | '/workspace/$workspaceId' | '/join/'
93+
fileRoutesById: FileRoutesById
9494
}
9595

9696
export interface RootRouteChildren {
97-
IndexRoute: typeof IndexRoute;
98-
WorkspaceWorkspaceIdRoute: typeof WorkspaceWorkspaceIdRoute;
99-
JoinIndexRoute: typeof JoinIndexRoute;
97+
IndexRoute: typeof IndexRoute
98+
WorkspaceWorkspaceIdRoute: typeof WorkspaceWorkspaceIdRoute
99+
JoinIndexRoute: typeof JoinIndexRoute
100100
}
101101

102102
const rootRouteChildren: RootRouteChildren = {
103103
IndexRoute: IndexRoute,
104104
WorkspaceWorkspaceIdRoute: WorkspaceWorkspaceIdRoute,
105105
JoinIndexRoute: JoinIndexRoute,
106-
};
106+
}
107107

108108
export const routeTree = rootRoute
109109
._addFileChildren(rootRouteChildren)
110-
._addFileTypes<FileRouteTypes>();
110+
._addFileTypes<FileRouteTypes>()
111111

112112
/* ROUTE_MANIFEST_START
113113
{

0 commit comments

Comments
 (0)