Skip to content

Commit

Permalink
refactor: 쿼리키 무효화 반영되지 않는 이슈 수정 (#1676)
Browse files Browse the repository at this point in the history
  • Loading branch information
seojisoosoo authored Nov 7, 2024
1 parent 07ea5e3 commit 1b6a80f
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/components/coffeechat/detail/SeemoreSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,25 @@ export default function SeemoreSelect({ memberId }: SeemoreSelectProp) {
router.push(playgroundLink.coffeechatEdit(memberId));
};

const handleDelete = () => {
const handleDelete = async () => {
mutate(undefined, {
onSuccess: async () => {
logSubmitEvent('coffeechatDelete');
queryClient.invalidateQueries({ queryKey: ['getRecentCoffeeChat'] });
queryClient.invalidateQueries({ queryKey: ['getMembersCoffeeChat'] });
queryClient.refetchQueries({ queryKey: ['getRecentCoffeeChat'] });
queryClient.refetchQueries({ queryKey: ['getMembersCoffeeChat'] });
queryClient.invalidateQueries({ queryKey: ['getMemberOfMe'] });
await toastOpen({ icon: 'success', content: '커피챗이 삭제되었어요. 다음에 또 만나요!' });
await router.push(playgroundLink.coffeechat());
try {
logSubmitEvent('coffeechatDelete');

await Promise.all([
queryClient.refetchQueries({ queryKey: ['getRecentCoffeeChat'] }),
queryClient.refetchQueries({ queryKey: ['getMembersCoffeeChat'] }),
queryClient.invalidateQueries({ queryKey: ['getMemberOfMe'] }),
]);

await toastOpen({ icon: 'success', content: '커피챗이 삭제되었어요. 다음에 또 만나요!' });
await router.push(playgroundLink.coffeechat());
} catch (error) {
console.error('쿼리 무효화 실패:', error);
await toastOpen({ icon: 'success', content: '커피챗이 삭제되었어요. 다음에 또 만나요!' });
await router.push(playgroundLink.coffeechat());
}
},
});
};
Expand Down

0 comments on commit 1b6a80f

Please sign in to comment.