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

Add timeout to batch modal update response #197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

vhaalmeida
Copy link
Contributor

What does this PR do? *

Add a timeout to handle state after update. Without it the error modal is displayed even when all requests went ok.

Without timeout:
Screenshot 2023-09-04 at 15 04 11
Screenshot 2023-09-04 at 15 04 17

How to test it? *

  • Log in with any user in workspace
  • visit
  • Create two orders with subscriptions.
  • Go to subscriptions page and change the address or the payment method for one of them. Wait for the batch modal appears, select all and save.

Related to / Depends on *

@vhaalmeida vhaalmeida requested a review from a team as a code owner September 4, 2023 18:08
})
}
// timeout added due to state not update instantaneously
setTimeout(() => {
Copy link
Contributor

@wagnerlduarte wagnerlduarte Sep 19, 2023

Choose a reason for hiding this comment

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

I believe you used setTimeout as a workaround to ensure that the state is updated.
Although it works, it may be better to transform the handleSuccess function into a Promise, to make this state update guarantee better.
Can you test whether removing setTimeout and changing handleSuccess to a Promise works well?

  private handleSuccess = (id: string) => {
    return new Promise<void>((resolve) => {
      this.setState(({ completed }) => {
        completed.push(id);
        return { completed };
      }, resolve);
    });
  }

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.

3 participants