fix: clear auction cache after cancellation
This commit is contained in:
1 parent
7c372f0392
commit
c6f5a7077f
2 files changed
+25
-12
No files matched your search
@@ -786,19 +786,31 @@ export default function AuctionPage() {
|
||||
const historyBackTo = `${location.pathname}${location.search}${location.hash}`;
|
||||
const canConfirmAuctionCancel = cancelConfirmText.trim() === '예';
|
||||
|
||||
async function invalidateAuctionData() {
|
||||
async function clearAuctionDataAfterCancel() {
|
||||
if (!id) return;
|
||||
const auctionQueryKey = ['auction', DEFAULT_COMMUNITY_ID, id] as const;
|
||||
const auctionHistoryQueryKey = [
|
||||
'auction-history',
|
||||
DEFAULT_COMMUNITY_ID,
|
||||
id,
|
||||
] as const;
|
||||
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['auction', DEFAULT_COMMUNITY_ID, id],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['auction-history', DEFAULT_COMMUNITY_ID, id],
|
||||
}),
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['match', DEFAULT_COMMUNITY_ID, id],
|
||||
queryClient.cancelQueries({ queryKey: auctionQueryKey, exact: true }),
|
||||
queryClient.cancelQueries({
|
||||
queryKey: auctionHistoryQueryKey,
|
||||
exact: true,
|
||||
}),
|
||||
]);
|
||||
queryClient.removeQueries({ queryKey: auctionQueryKey, exact: true });
|
||||
queryClient.removeQueries({
|
||||
queryKey: auctionHistoryQueryKey,
|
||||
exact: true,
|
||||
});
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ['match', DEFAULT_COMMUNITY_ID, id],
|
||||
exact: true,
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@@ -848,7 +860,7 @@ export default function AuctionPage() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!socket.resetAt || !id) return;
|
||||
void invalidateAuctionData().finally(() => {
|
||||
void clearAuctionDataAfterCancel().finally(() => {
|
||||
navigate(`/match/${id}`, { replace: true });
|
||||
});
|
||||
}, [id, navigate, socket.resetAt]);
|
||||
@@ -959,7 +971,7 @@ export default function AuctionPage() {
|
||||
onSuccess: async () => {
|
||||
setShowCancelModal(false);
|
||||
setCancelConfirmText('');
|
||||
await invalidateAuctionData();
|
||||
await clearAuctionDataAfterCancel();
|
||||
navigate(`/match/${id}`, { replace: true });
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user