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

fix: refetch action data after the motion countdown timer is finished #3948

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rumzledz
Copy link
Contributor

@rumzledz rumzledz commented Dec 13, 2024

Description

Special shoutouts to @davecreaser for helping me figure out that there was a little bit of delay on Contract side when it comes to the motion state updates 💯

So I ended up changing my solution to using the safe polling timeout as the interval delay for refetching the motion state. And it works like a charm ✨

ap-staking

Testing

Note

There is a bug on master whereby if you don't stake the motion and you just allow the motion countdown timer to finish, then the button gets stuck to Pending. We'll fix this in a separate PR.

  1. Install the Reputation extension
  2. On the Reputation extension's config page, select "Custom (Advanced)
  3. Set the following fields to 0.005 (this will make your life easier)
  • Staking Phase Duration
  • Voting Phase Duration
  • Reveal Phase Duration
  1. Enable the Reputation extension
  2. Bring up the Advanced Payment form
  3. Set the Decision method to Staking
  4. Fill in all other required fields
  5. Submit the form
  6. Wait for the Payment Builder Widget to come up
  7. Confirm the details
  8. Click Fund
  9. [IMPORTANT] On the Funding modal, choose the Reputation decision method:
image
  1. Support the motion and fully stake it
  2. Wait for the countdown timer to finish
  3. Verify that eventually:
  • the motion progresses to the next step
  • you can see the Finalize button

Resolves #3729

@rumzledz rumzledz self-assigned this Dec 13, 2024
@rumzledz rumzledz marked this pull request as ready for review December 13, 2024 21:20
@rumzledz rumzledz requested a review from a team as a code owner December 13, 2024 21:20
mmioana
mmioana previously approved these changes Dec 16, 2024
Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Nice work fixing this issue @rumzledz 🙌

Installed the Reputation extension
Screenshot 2024-12-16 at 10 17 41

Created an Advanced Payment using staking
Screenshot 2024-12-16 at 10 18 11

Selected Reputation for the funding step
Screenshot 2024-12-16 at 10 18 40

And the motion state updates without getting stuck 🎉

Screen.Recording.2024-12-16.at.10.21.38.mov

@rumzledz I tried to check what is actually happening in the code after reading your expanded description, and noticed that once the timer finishes actually this effect doesn't get triggered

  /* Ensures motion state is kept in sync with motion data */
  useEffect(() => {
    if (action?.motionData) {
      refetchMotionState();
    }
  }, [action?.motionData, refetchMotionState]);

Maybe it's worth investigating in a future issue why this is happening, but for the time being, your solution is good 🙌

Copy link
Contributor

@davecreaser davecreaser left a comment

Choose a reason for hiding this comment

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

Nice investigation @rumzledz! It looks like it's still slightly flaky though, for me it's still getting stuck once in a while. Maybe take a look at what @mmioana suggested before, and if not or if it's still being weird then we can pair up on it if you like. Also if this is only happening to me and it's working every time for others then just ignore me :)

Screenshot 2024-12-16 at 16 09 54 Screenshot 2024-12-16 at 16 11 24 Screenshot 2024-12-16 at 16 13 35

@rumzledz
Copy link
Contributor Author

Hey @davecreaser what @mmioana has said is practically what I explained on my description 😅 She's basically saying that the useEffect hook isn't running and the reason for that is due to how our queries are not resolving.

The useEffect hook she mentioned:

useEffect(() => {
  if (action?.motionData) {
    refetchMotionState();
  }
}, [action?.motionData, refetchMotionState]);

Runs based on action?.motionData. The issue is that the query in charge of fetching action is not resolving. Here's the part of my description that explains this:

image

I'll jump on a call with you to see what's going on with your local 👌

@rumzledz
Copy link
Contributor Author

rumzledz commented Dec 16, 2024

@davecreaser @mmioana actually on 2nd look at Ioana's comment, the useEffect hook she mentioned is not the actual hook that needs to run in this scenario.

The hook that needs to resolve in this scenario is useGetMotionStateQuery and it's not resolving. It's basically being called after the Motion countdown timer finishes. But after it's called, it's not resolving, and so its onCompleted callback is not running. This callback is supposed to be the one that refetches the action data which would then update the Payment builder widget

@rumzledz rumzledz changed the title fix: refetch action data after the motion countdown timer is finsihed fix: refetch action data after the motion countdown timer is finished Dec 16, 2024
@rumzledz rumzledz marked this pull request as draft December 17, 2024 08:12
@rumzledz rumzledz force-pushed the fix/3729-staking-stuck-on-funding branch from 339557f to 8699e83 Compare December 17, 2024 12:27
@rumzledz rumzledz marked this pull request as ready for review December 17, 2024 12:30
@rumzledz rumzledz force-pushed the fix/3729-staking-stuck-on-funding branch from 8699e83 to ae56c9d Compare December 17, 2024 12:31
@rumzledz rumzledz force-pushed the fix/3729-staking-stuck-on-funding branch from ae56c9d to d2f4a9b Compare December 17, 2024 12:32
@rumzledz rumzledz requested a review from a team December 17, 2024 12:35
@rumzledz
Copy link
Contributor Author

@mmioana @davecreaser I've updated the code and I'm pretty confident about this one 🙌 (famous last words 😂 ) Can you please check again when you get the chance? obrigado & grazie! 🙏

Copy link
Contributor

@mmioana mmioana left a comment

Choose a reason for hiding this comment

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

Really big thumbs up both to you @rumzledz and @davecreaser for this solution 🙌

Installed the extension
Screenshot 2024-12-18 at 21 52 41

Created an advanced payment using Staking
Screenshot 2024-12-18 at 21 54 33

Selected Reputation as the funding method
Screenshot 2024-12-18 at 21 54 49

And it all works flawlessly ✨

Screen.Recording.2024-12-18.at.21.54.55.mov

Nice job!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Advanced payment] Endless loader displayed, and status does not update on the Funding step after staking.
3 participants