Skip to content

Commit

Permalink
fix: invalidate queries manually
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoov committed Jul 3, 2024
1 parent 7d00b99 commit 6ba153c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/web-client/src/components/board/BoardJobWriteSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Link, useHistory } from 'react-router-dom';
import { stringify } from 'qs';
import { createStyles } from 'antd-style';
import { UploadOutlined } from '@ant-design/icons';
import { useQueryClient } from '@tanstack/react-query';
import { ApiError, CustomApi, PostControllerService, PostCreateRequest, queryKey, useAppMutation, useAppQuery } from '~/lib/api-v2';
import { Block, WhiteBlock } from '~/styles/common/Block.styles';
import { MENU } from '~/constants/menus';
Expand Down Expand Up @@ -57,6 +58,7 @@ export default function BoardJobWriteSection({ postId }: { postId: number }) {
const { styles } = useStyles();
const message = useMessage();
const history = useHistory();
const queryClient = useQueryClient();

const editorRef = useRef<Editor | null>(null);
const form = useForm<z.infer<typeof schema>>({
Expand Down Expand Up @@ -165,6 +167,9 @@ export default function BoardJobWriteSection({ postId }: { postId: number }) {
onSuccess() {
message.success('글이 수정되었습니다.');
history.push(`/${MENU.BOARD}/${postId}`);
queryClient.invalidateQueries({
queryKey: queryKey.post.post(postId),
});
},
},
);
Expand All @@ -190,6 +195,9 @@ export default function BoardJobWriteSection({ postId }: { postId: number }) {
onSuccess() {
message.success('글이 작성되었습니다.');
history.push(`/${MENU.BOARD}?${stringify({ boardType: 'JOB' })}`);
queryClient.invalidateQueries({
queryKey: queryKey.post.all('JOB', 0),
});
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { stringify } from 'qs';
import { createStyles } from 'antd-style';
import { match } from 'ts-pattern';
import { UploadOutlined } from '@ant-design/icons';
import { useQueryClient } from '@tanstack/react-query';
import { ApiError, CustomApi, PostControllerService, queryKey, useAppMutation, useAppQuery } from '~/lib/api-v2';
import { Block, WhiteBlock } from '~/styles/common/Block.styles';
import { MENU } from '~/constants/menus';
Expand Down Expand Up @@ -55,6 +56,7 @@ export default function BoardNormalWriteSection({ boardType, postId }: { boardTy
const history = useHistory();
const message = useMessage();
const loginId = useAppSelector((state) => state.auth.user.memberId);
const queryClient = useQueryClient();

const editorRef = useRef<Editor | null>(null);

Expand Down Expand Up @@ -119,6 +121,9 @@ export default function BoardNormalWriteSection({ boardType, postId }: { boardTy
onSuccess() {
message.success('글이 수정되었습니다.');
history.push(`/${MENU.BOARD}/${postId}`);
queryClient.invalidateQueries({
queryKey: queryKey.post.post(postId),
});
},
},
);
Expand All @@ -140,6 +145,9 @@ export default function BoardNormalWriteSection({ boardType, postId }: { boardTy
onSuccess() {
message.success('글이 작성되었습니다.');
history.push(`/${MENU.BOARD}?${stringify({ boardType })}`);
queryClient.invalidateQueries({
queryKey: queryKey.post.all(boardType, 0),
});
},
},
);
Expand Down

0 comments on commit 6ba153c

Please sign in to comment.