0xStation / proposer

1 stars 0 forks source link

Foxes fix: make sure rfp status is reading from source of truth #809

Closed kristencheung closed 1 year ago

kristencheung commented 1 year ago

What's included in this pr + description

On a workspace's rfps page, the open/close state changes inaccurately when clicking in and out of an RFP: when clicking to the second page, then clicking on an RFP, then clicking to go back to the RFPs page, the rfp's open/close state is inaccurate.

The problem is we're reading the RFP's state from two different sources, the db and local state.

When we are clicking through the different pages, the change in props of the RFPCard doesn't a trigger a re-render of the RfpCard's local state, but the data from the db has changed due to the new RFPs being fetched via pagination.

We run into an issue of wanting to trigger a re-render of the RFPCard which would change the local state, but then changing the local state would defeat its purpose for optimistically modifying the open/close state when the rfp's start date / end date dynamically changes.

The fix is to rely on one source of truth (the db) and refetch the data in the useScheduleCallback hook instead of changing local state.

Additionally, I added a query param so that when you click into the RFP that's a few pages in and then go back to the rfps page, you land on the same source page.

Motivation & Context

Ali recently messaged us pointing out this issue:

image

Steps to test

  1. Visit a workspace with multiple pages of RFPs with different open/close states
  2. Click to a page that's not the first on the workspace rfps tab
  3. Click into an RFP
  4. Navigate back to the workspace's rfps tab
  5. Ensure the open/close state hasn't changed and that you land on the same page that displays the RFP you clicked into.
vercel[bot] commented 1 year ago

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

Name Status Preview Updated
web ✅ Ready (Inspect) Visit Preview Dec 19, 2022 at 7:27PM (UTC)