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: upload 중일 경우 재요청 보내지 않도록 처리 추가 #376

Merged
merged 1 commit into from
Oct 16, 2023
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
15 changes: 10 additions & 5 deletions src/comment/ui/bookmark/CommentUploadInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ const CommentUploadInput = () => {
initComment();
};

const { mutate: postComment } = usePOSTCommentQuery({
bookmarkId: bookmarkId ?? '',
initComment,
});
const { mutate: editComment } = usePUTCommentQuery({
const { mutate: postComment, isLoading: isPostLoading } = usePOSTCommentQuery(
{
bookmarkId: bookmarkId ?? '',
initComment,
},
);
const { mutate: editComment, isLoading: isEditLoading } = usePUTCommentQuery({
bookmarkId: bookmarkId ?? '',
initComment,
});
Expand All @@ -37,6 +39,9 @@ const CommentUploadInput = () => {
event: React.FormEvent<HTMLFormElement> | MouseEvent<HTMLButtonElement>,
) => {
event.preventDefault();
if (isPostLoading || isEditLoading) return;
if (!comment.content) return;

if (mode === 'CREATE') {
postComment({
bookmarkId: Number(id),
Expand Down
22 changes: 12 additions & 10 deletions src/pages/BookmarkAddPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,23 @@ const BookmarkAddPage = () => {
);

const { memberId } = useAuthStore();
const { mutate: postBookmark } = usePOSTBookmarkMutation({
resetAll: {
resetAllInputs,
resetCategory: () => {
setSelectedCategoryId(0);
setCategoryList(toggleCategory(0));
const { mutate: postBookmark, isLoading: isPostLoading } =
usePOSTBookmarkMutation({
resetAll: {
resetAllInputs,
resetCategory: () => {
setSelectedCategoryId(0);
setCategoryList(toggleCategory(0));
},
resetVisibility: () => onClickPublishScoped('SCOPE_PUBLIC'),
},
resetVisibility: () => onClickPublishScoped('SCOPE_PUBLIC'),
},
memberId,
});
memberId,
});

const { fireToast } = useToast();

const onClickSubmitButton = () => {
if (isPostLoading) return;
if (isBookmarkError) {
fireToast({
mode: 'ERROR',
Expand Down
17 changes: 10 additions & 7 deletions src/pages/CategoryManagePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ const CategoryManagePage = ({ mode }: CategoryManagePageProps) => {
};

// 2. 저장 버튼 > 저장
const { mutate: postCategory } = usePOSTCategoryMutation({
memberId,
});
const { mutate: putCategory } = usePUTCategoryMutation({
memberId,
categoryId: categoryId ?? '',
});
const { mutate: postCategory, isLoading: isPostLoading } =
usePOSTCategoryMutation({
memberId,
});
const { mutate: putCategory, isLoading: isPutLoading } =
usePUTCategoryMutation({
memberId,
categoryId: categoryId ?? '',
});
const onClickSave = () => {
if (isPostLoading || isPutLoading) return;
if (!categoryName.length) {
fireToast({ message: '앗! 카테고리 이름이 비어있어요', mode: 'ERROR' });
return;
Expand Down