From 25a2632da925b4890c5c994881bd453a30164ef3 Mon Sep 17 00:00:00 2001 From: William Luke Date: Thu, 9 Apr 2026 16:23:13 +0300 Subject: [PATCH] fix: update image cache immediately after hero image upload Use setData to directly update TanStack Query cache with new image URLs instead of invalidate/refetch, so the UI reflects changes without reload. Co-Authored-By: Claude Opus 4.6 --- src/app/(main)/pools/[address]/pool-client-page.tsx | 4 +++- src/components/voucher/voucher-hero-section.tsx | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/(main)/pools/[address]/pool-client-page.tsx b/src/app/(main)/pools/[address]/pool-client-page.tsx index a970dc5e..30ab7093 100644 --- a/src/app/(main)/pools/[address]/pool-client-page.tsx +++ b/src/app/(main)/pools/[address]/pool-client-page.tsx @@ -37,7 +37,9 @@ export function PoolClientPage() { pool_address: pool_address, banner_url: url, }); - await utils.pool.get.refetch(pool_address); + utils.pool.get.setData(pool_address, (old) => + old ? { ...old, banner_url: url } : old + ); toast.success("Banner updated"); } catch (error) { console.error(error); diff --git a/src/components/voucher/voucher-hero-section.tsx b/src/components/voucher/voucher-hero-section.tsx index 31808a8e..837854c6 100644 --- a/src/components/voucher/voucher-hero-section.tsx +++ b/src/components/voucher/voucher-hero-section.tsx @@ -38,7 +38,10 @@ export function VoucherHeroSection({ const handleBannerSave = async (url: string) => { try { await update.mutateAsync({ voucherAddress: address, bannerUrl: url }); - await utils.voucher.invalidate(); + utils.voucher.byAddress.setData( + { voucherAddress: address }, + (old) => (old ? { ...old, banner_url: url } : old) + ); toast.success("Banner updated"); } catch (error) { console.error(error); @@ -49,7 +52,10 @@ export function VoucherHeroSection({ const handleIconSave = async (url: string) => { try { await update.mutateAsync({ voucherAddress: address, iconUrl: url }); - await utils.voucher.invalidate(); + utils.voucher.byAddress.setData( + { voucherAddress: address }, + (old) => (old ? { ...old, icon_url: url } : old) + ); toast.success("Icon updated"); } catch (error) { console.error(error);