Skip to content

Commit b5017a8

Browse files
committed
chore: 필요없는 코드 제거
1 parent 09be555 commit b5017a8

File tree

5 files changed

+4
-64
lines changed

5 files changed

+4
-64
lines changed

apps/frontend/src/features/editor/model/useEditorTitle.ts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { useState } from "react";
2-
import { JSONContent } from "novel";
32

43
import Emoji from "@/shared/ui/Emoji";
54

65
import useYDocStore from "@/shared/model/ydocStore";
76
import { useYText } from "@/shared/model/useYText";
8-
import { useOptimisticUpdatePage } from "@/features/pageSidebar/api/usePages";
97

108
interface Emoji {
119
id: string;
@@ -16,34 +14,18 @@ interface Emoji {
1614
unified: string;
1715
}
1816

19-
export const useEditorTitle = (
20-
currentPage: number,
21-
pageContent: JSONContent,
22-
) => {
17+
export const useEditorTitle = (currentPage: number) => {
2318
const { ydoc } = useYDocStore();
2419
const [title, setYTitle] = useYText(ydoc, "title", currentPage);
2520
const [emoji, setYEmoji] = useYText(ydoc, "emoji", currentPage);
2621
const [isEmojiPickerOpen, setIsEmojiPickerOpen] = useState(false);
2722

28-
const optimisticUpdatePageMutation = useOptimisticUpdatePage({
29-
id: currentPage ?? 0,
30-
});
31-
3223
const handleTitleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
3324
setYTitle(e.target.value);
34-
35-
optimisticUpdatePageMutation.mutate({
36-
pageData: { title: e.target.value, content: pageContent, emoji },
37-
});
3825
};
3926

4027
const handleEmojiClick = ({ native }: Emoji) => {
4128
setYEmoji(native);
42-
43-
optimisticUpdatePageMutation.mutate({
44-
pageData: { title, content: pageContent, emoji: native },
45-
});
46-
4729
setIsEmojiPickerOpen(false);
4830
};
4931

@@ -61,11 +43,6 @@ export const useEditorTitle = (
6143
e.stopPropagation();
6244

6345
setYEmoji("");
64-
65-
optimisticUpdatePageMutation.mutate({
66-
pageData: { title, content: pageContent, emoji: "" },
67-
});
68-
6946
setIsEmojiPickerOpen(false);
7047
};
7148

apps/frontend/src/features/editor/ui/EditorTitle/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Picker from "@emoji-mart/react";
2-
import { JSONContent } from "novel";
32

43
import { useEditorTitle } from "@/features/editor/model/useEditorTitle";
54
import Emoji from "@/shared/ui/Emoji";
@@ -8,7 +7,6 @@ import { cn } from "@/shared/lib";
87

98
interface EditorTitleProps {
109
currentPage: number;
11-
pageContent: JSONContent;
1210
}
1311

1412
interface Emoji {
@@ -20,7 +18,7 @@ interface Emoji {
2018
unified: string;
2119
}
2220

23-
export function EditorTitle({ currentPage, pageContent }: EditorTitleProps) {
21+
export function EditorTitle({ currentPage }: EditorTitleProps) {
2422
const {
2523
emoji,
2624
title,
@@ -30,7 +28,7 @@ export function EditorTitle({ currentPage, pageContent }: EditorTitleProps) {
3028
handleEmojiClick,
3129
handleEmojiOutsideClick,
3230
handleTitleChange,
33-
} = useEditorTitle(currentPage, pageContent);
31+
} = useEditorTitle(currentPage);
3432

3533
return (
3634
<div className="flex flex-col gap-3">

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

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,3 @@ export const usePages = () => {
6161

6262
return { pages, isError };
6363
};
64-
65-
export const useOptimisticUpdatePage = ({ id }: { id: number }) => {
66-
const queryClient = useQueryClient();
67-
68-
return useMutation({
69-
mutationFn: ({ pageData }: { pageData: UpdatePageRequest }) =>
70-
updatePage(id, pageData),
71-
onMutate: async ({ pageData }: { pageData: UpdatePageRequest }) => {
72-
await queryClient.cancelQueries({ queryKey: ["page", id] });
73-
74-
const snapshot = queryClient.getQueryData(["page", id]);
75-
76-
queryClient.setQueryData(["page", id], pageData);
77-
78-
return () => {
79-
queryClient.setQueryData(["page", id], snapshot);
80-
};
81-
},
82-
onError: (_err, _variables, rollback) => {
83-
rollback?.();
84-
},
85-
onSettled: () => {
86-
// queryClient.invalidateQueries({ queryKey: ["page", id] });
87-
queryClient.invalidateQueries({ queryKey: ["pages"] });
88-
},
89-
});
90-
};

apps/frontend/src/widgets/EditorView/hooks/useEditorView.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ export const useEditorView = () => {
3434
};
3535
}, [currentPage]);
3636

37-
const pageContent = page?.content ?? {};
38-
3937
const handleEditorUpdate = useDebouncedCallback(async () => {
4038
if (currentPage === null) {
4139
return;
@@ -53,7 +51,6 @@ export const useEditorView = () => {
5351
ydoc,
5452
provider,
5553
saveStatus,
56-
pageContent,
5754
handleEditorUpdate,
5855
users,
5956
};

apps/frontend/src/widgets/EditorView/ui/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function EditorView() {
1313
ydoc,
1414
provider,
1515
saveStatus,
16-
pageContent,
1716
handleEditorUpdate,
1817
users,
1918
} = useEditorView();
@@ -39,11 +38,7 @@ export function EditorView() {
3938
isMaximized && "mx-auto w-[800px] py-4",
4039
)}
4140
>
42-
<EditorTitle
43-
key={currentPage}
44-
currentPage={currentPage}
45-
pageContent={pageContent}
46-
/>
41+
<EditorTitle key={currentPage} currentPage={currentPage} />
4742
<ActiveUser
4843
users={users.filter(
4944
(user) => user.currentPageId === currentPage.toString(),

0 commit comments

Comments
 (0)