T
TanStack2y ago
blank-aquamarine

Wait invalidate infinite query

const handleDeclineLeadOffer = async () => {
if (!declineOfferReason) return showToast('Escolha uma opção de declínio');

if (shouldOnlyDeclineMeeting) {
await meetingAction({
action: MeetingActionEnum.DECLINED,
leadType,
meetingId: lead?.meeting?.id as string,
declinedReason: declineOfferReason,
});

return;
}

await updateLead({
type: leadType,
leadId: leadId || (lead?.id as string),
status: LeadMundoInvestStatusEnum.FINALIZADO,
declinedReason: declineOfferReason,
});

await queryClient.invalidateQueries(modalOptions?.invalidateQueriesKey);

goBack();

return showToast('Declínio realizado com sucesso!');
};
const handleDeclineLeadOffer = async () => {
if (!declineOfferReason) return showToast('Escolha uma opção de declínio');

if (shouldOnlyDeclineMeeting) {
await meetingAction({
action: MeetingActionEnum.DECLINED,
leadType,
meetingId: lead?.meeting?.id as string,
declinedReason: declineOfferReason,
});

return;
}

await updateLead({
type: leadType,
leadId: leadId || (lead?.id as string),
status: LeadMundoInvestStatusEnum.FINALIZADO,
declinedReason: declineOfferReason,
});

await queryClient.invalidateQueries(modalOptions?.invalidateQueriesKey);

goBack();

return showToast('Declínio realizado com sucesso!');
};
I have this function, I would like to await the invalidation because when I go back, I need to refetch all pages again and the card I "removed" takes some time to disappear, causing some bad user experience, there is a way to invalidate and wait all pages to be refetch before going back?
4 Replies
foreign-sapphire
foreign-sapphire2y ago
Instead of invalidating I think you can do refetch?
foreign-sapphire
foreign-sapphire2y ago
foreign-sapphire
foreign-sapphire2y ago
I think query client fetch query will do nothing if the cache is not stale
blank-aquamarine
blank-aquamarineOP2y ago
yeah, thats work thank you!

Did you find this page helpful?