-- **Soft refresh after session writes:** `UPDATE_ZIPCODE`, `UPDATE_PICKUP` (`selectPickup`), `SELECT_DELIVERY_SHIPPING_OPTION`, `RESET_FULFILLMENT_METHOD`, and `CLEAR_ZIPCODE` no longer trigger `window.location.reload()`. Instead, after `POST /api/sessions` resolves (and the new `vtex_segment` cookie carrying the updated `deliveryZonesHash` / `pickupPointsHash` is in place), the hook refetches **only** an explicit allowlist of `vtex.store-resources` queries that vary by `@withSegment` (`facetsV2`, `productSearchV3`, `Products`, `Product`, `sponsoredProducts`, `ProductRecommendations`) instead of refetching every observable query — keeping the React tree alive and avoiding traffic for segment-independent queries. `productSearchV3` is reset to the **first page** since a location change invalidates the current pagination: both `from` and `to` are overridden (`from: 0`, `to: to - from`, preserving the page size as `search-result` derives it), and the `page` query string is reset to the first page **through render-runtime** (`setQuery({ page: undefined }, { replace: true })`, only when currently past page 1). Using render-runtime instead of `history.replaceState` is what lets `vtex.search-result` observe the change and reset its "load more" pagination reducer (so the next "load more" goes to page 2, not the page after the stale one — see the paired `vtex.search-result` change). `location.reload()` is kept as a guaranteed fallback when no `ApolloProvider` is mounted, the Apollo internals are inaccessible, or a refetch throws.
0 commit comments