fix(portfolio): actually refetch the property table after adding properties

invalidateQueries only refetches mounted queries; the property table isn't
mounted on the add page, and useProperties' refetchOnMount: false then
suppresses the refetch when it does mount — so the invalidation never
produced a fetch. Removing the cached query instead guarantees the initial
fetch on mount.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Khalim Conn-Kowlessar 2026-07-07 17:50:47 +00:00
parent 0b475d8e03
commit 2caac6fa6c

View file

@ -93,9 +93,11 @@ export default function AddPropertiesClient({
setDone(totals);
// Added properties change the search's alreadyInPortfolio flags
queryClient.invalidateQueries(["postcode-search", portfolioId]);
// …and the portfolio's property table, which otherwise stays stale for
// 5 minutes (useProperties staleTime) on top of the router cache.
queryClient.invalidateQueries(["properties", portfolioId]);
// …and the portfolio's property table. Remove, don't invalidate: the
// table isn't mounted here, and useProperties sets refetchOnMount:
// false, so a stale-marked query would never actually refetch — only
// an empty cache guarantees a fresh fetch when the table mounts.
queryClient.removeQueries(["properties", portfolioId]);
router.refresh();
},
});