Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reviewing: Rerun query when accepting & un-accepting changes #86

Conversation

ndelangen
Copy link
Member

@ndelangen ndelangen commented Sep 7, 2023

What I did

As per @tmeasday's suggestion: I added a call to rerun() to the onAccept & onUnaccept callbacks making mutation

How to test

  • open storybook in repo
  • make a change thaty will show up in the UI
  • start a build & wait for it to report changes
  • accept the change, assert this toggles to the reviewed state fast
  • un-accept the change, assert this toggles to unreviewed state fast
📦 Published PR as canary version: 0.0.62--canary.86.a78ce21.0

✨ Test out this PR locally via:

npm install @chromaui/[email protected]
# or 
yarn add @chromaui/[email protected]

@linear
Copy link

linear bot commented Sep 7, 2023

AP-3637 Accept/unaccept buttons don't immediately update after update

They only update when we've polled for new data. The mutation should trigger a rerun of the query.

@ndelangen ndelangen self-assigned this Sep 7, 2023
@ndelangen ndelangen added the bug Classification: Something isn't working label Sep 7, 2023
Copy link
Member

@tmeasday tmeasday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Maybe we should rename the var from rerun?

I tried it out and it sure did work. It does briefly show "Accept" again (I guess while the query is in flight). I guess to fix it we'd need to implement our own state var for isReviewing rather than relying on URQL's mutation state. WDYT?

@ndelangen
Copy link
Member Author

Hmmm.. I'm not sure.. it seems like there should also really be some sort of loading indicator?
@ghengeveld How do you feel we should solve this?

@tmeasday
Copy link
Member

tmeasday commented Sep 7, 2023

it seems like there should also really be some sort of loading indicator?

There is a loading indicator, it appears while the mutation is running. It just doesn't show up while the rerun query is running, so you see "Accept" again for a moment.

I'm happy to move on for now and reconsider these UX nuances later for sure, btw. But to do what we want here I think we'd do something like:

const [isReviewing, setIsReviewing] = useState(false);
onAccepting = async () => {
  try {
    setIsReviewing(true);
    await reviewTest(...)

    await rerun();
  } finally {
    setIsReviewing(false);
  }
}

So not super complicated IMO.

@ndelangen
Copy link
Member Author

@tmeasday when I added rerun() I wondered if I should await it.. and I decided it should not, because rerun (according to types) is not an async function.

@ndelangen ndelangen merged commit 6532b1d into main Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Classification: Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants