balancer / frontend-v3

Deprecated, the app was moved into our frontend monorepo.
https://github.com/balancer/frontend-monorepo
MIT License
8 stars 12 forks source link

fix: avoid unwanted background simulation refetches #1082

Closed agualis closed 1 month ago

agualis commented 1 month ago

The reason of this PR is explained in this comment: https://github.com/balancer/frontend-v3/pull/1082/files#diff-513339dcf8a351b65d33cd277aa6442c85248d22a53b788aa262c7e2e5fddb36R34

This was previously solved with placeholderData option in the queryClient but that was causing other issues, so we had to remove that setup.

How to reproduce: Example with Claim and Unstake flow You can reproduce it in main branch if you have something to claim in a staked pool in polygon

  1. Remove this code fromreact-query.provider.tsx (it was causing other issues and it will be deleted as part of the current PR)

    queryClient.setDefaultOptions({
    queries: {
    /* Avoids problems in simulation and build queries when the user navigates away from the page while waiting for a tx confirmation.
      Without this option, navigating to another tab and coming back was causing useRemoveLiquidityBuildCallDataQuery to be undefined leading to unexpected thrown errors.
    
      This is equivalent to setting the old keepPreviousData: true option
      More info:
        https://github.com/TanStack/query/discussions/6460
    */
    placeholderData: (prev: any) => prev,
    },
    })
  2. Trigger the “Claim and unstake” tx, confirm in your wallet and go between balancer and other browser tabs back and forth until you get this behaviour:

https://github.com/user-attachments/assets/0ef53fd8-8327-4a2d-9d8e-467679ed8864

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
frontend-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 13, 2024 10:53am
test-v3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 13, 2024 10:53am