Skip to content

Commit 9f686c8

Browse files
authored
Merge pull request #349 from boostcampwm-2024/bug-fe-#348
사용하지 않는 pages 쿼리 제거
2 parents bf0b295 + 3038887 commit 9f686c8

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed
Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
1-
import {
2-
useQuery,
3-
useMutation,
4-
useQueryClient,
5-
skipToken,
6-
} from "@tanstack/react-query";
1+
import { useQuery, useMutation, skipToken } from "@tanstack/react-query";
72

8-
import {
9-
getPages,
10-
createPage,
11-
deletePage,
12-
getPage,
13-
} from "@/entities/page/api/pageApi";
3+
import { createPage, deletePage, getPage } from "@/entities/page/api/pageApi";
144
import { CreatePageRequest } from "@/entities/page/model/pageTypes";
155

166
export const usePage = (currentPage: number | null) => {
@@ -27,33 +17,14 @@ export const usePage = (currentPage: number | null) => {
2717
};
2818

2919
export const useCreatePage = () => {
30-
const queryClient = useQueryClient();
31-
3220
return useMutation({
3321
mutationFn: ({ title, content, x, y, emoji }: CreatePageRequest) =>
3422
createPage({ title, content, x, y, emoji }),
35-
onSuccess: () => {
36-
queryClient.invalidateQueries({ queryKey: ["pages"] });
37-
},
3823
});
3924
};
4025

4126
export const useDeletePage = () => {
42-
const queryClient = useQueryClient();
43-
4427
return useMutation({
4528
mutationFn: ({ id }: { id: number }) => deletePage(id),
46-
onSuccess: () => {
47-
queryClient.invalidateQueries({ queryKey: ["pages"] });
48-
},
49-
});
50-
};
51-
52-
export const usePages = (workspaceId: string) => {
53-
const { data: pages, isError } = useQuery({
54-
queryKey: ["pages", workspaceId],
55-
queryFn: workspaceId ? () => getPages(workspaceId) : skipToken,
5629
});
57-
58-
return { pages, isError };
5930
};

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,20 @@ import { PencilLine } from "lucide-react";
22

33
import Button from "@/shared/ui/Button";
44

5-
import { useCreatePage, usePages } from "@/features/pageSidebar/api/usePages";
5+
import { useCreatePage } 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";
109

1110
export function Tools() {
1211
const { setCurrentPage } = usePageStore();
13-
const workspace = useWorkspace();
14-
const { pages } = usePages(workspace);
12+
1513
const createMutation = useCreatePage();
1614
const { ydoc } = useYDocStore();
1715

1816
return (
1917
<Button
20-
className={`${!pages && "disabled"} flex w-full flex-row items-center gap-1 rounded-sm px-2 py-1 font-medium hover:bg-neutral-100`}
18+
className={`flex w-full flex-row items-center gap-1 rounded-sm px-2 py-1 font-medium hover:bg-neutral-100`}
2119
onClick={() => {
2220
createMutation
2321
.mutateAsync({

0 commit comments

Comments
 (0)