Skip to content

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);
    });
  }

v-hansen and others added 2 commits September 19, 2023 16:54
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.

4 participants