Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Fix/#471 ] 수정하기 페이지 최신화 안되는 거 수정 #472

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/pages/postPage/PostPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ const PostPage = () => {
writer: tempAnonymous ? '작자미상' : '필명',
});
}
}, [viewType, editPostId, continueTempPost, tempTitle, tempContent, editPostTitle]);
}, [viewType, continueTempPost, tempTitle, tempContent, editPostTitle, editPostContent]);

// 수정하기 제출하기
const { mutate: putEditContent } = usePutEditContent({
Expand All @@ -339,9 +339,11 @@ const PostPage = () => {
return;
} else {
try {
await handleImageUpload(url, fileName, imageFile, editorVal.imageUrl);
const imgUrl = await handleImageUpload(url, fileName, imageFile, editorVal.imageUrl);
if (imgUrl) {
putEditContent(imgUrl);
}

putEditContent();
handleShowModal();
setEditorModalType('editContent');
editorFlowModalDispatch({ type: 'editContent' });
Expand Down
7 changes: 3 additions & 4 deletions src/pages/postPage/hooks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const usePresignedUrl = (): PresignedUrlQueryResult => {
// 글 수정시 글 조회 GET
export const useGetEditPostContent = (postId: string, isEditView: boolean) => {
const { data } = useQuery({
queryKey: [QUERY_KEY_POST.getEditPostContent, postId],
queryKey: [QUERY_KEY_POST.getEditPostContent, postId, isEditView],
queryFn: () => fetchEditPostContent(postId),
enabled: !!isEditView,
});
Expand Down Expand Up @@ -166,7 +166,6 @@ export const usePutEditContent = ({
topicId,
title,
content,
imageUrl,
anonymous,
postId,
contentWithoutTag,
Expand All @@ -180,14 +179,13 @@ export const usePutEditContent = ({
topicId,
title,
content,
imageUrl,
anonymous,
postId,
contentWithoutTag,
setPostErrorMessage,
},
],
mutationFn: () =>
mutationFn: (imageUrl: string) =>
editPutContent({
topicId,
title,
Expand All @@ -200,6 +198,7 @@ export const usePutEditContent = ({
}),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: [QUERY_KEY_POST_DETAIL.getPostDetail, postId] });
queryClient.invalidateQueries({ queryKey: [QUERY_KEY_POST.getEditPostContent, postId] });
},
});
return data;
Expand Down