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

warning if delegating to a pool in the blacklist #806

Conversation

v-almonacid
Copy link
Contributor

@v-almonacid v-almonacid commented Mar 6, 2020

This PR integrates the reputation endpoint defined in EmIP6 (see Yoroi frontend's PR for reference Emurgo/yoroi-frontend#1329)

In terms of design I just reused a typical "warning modal" that we have used for similar purposes.

Example for a pool with node_flags = 1:

Screenshot 2020-03-06 at 19 25 49

Clicking "I understand" sends the user to the "delegation confirmation" screen so their can still change their mind and choose not to send the delegation tx.

@v-almonacid v-almonacid self-assigned this Mar 9, 2020
@v-almonacid v-almonacid marked this pull request as ready for review March 9, 2020 12:11
const pools: Array<SelectedPool> = JSON.parse(
decodeURI(event.nativeEvent.data),
)
setBusy(true) // trigger "please wait" modal
Copy link
Contributor

Choose a reason for hiding this comment

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

not specific to just here, but instead of doing setBusy with finallys everywhere which is error prone during refactoring, maybe it would have made more sense to make setBusy take an argument that's a lambda which guarantees setBusy is always set to false after the lambda is done running. Something like

wrapBusy(func: void => Promise<void>): Promise<void> {
    setBusy(true);
    try {
        await func();
    } finally {
        setBusy(false);
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SebastienGllmt I added a wrapper as you suggested. I see the point on doing this but we must be careful when using this pattern with a navigation.navigate() call. If after navigating the origin component is unmounted, then setBusy will try to update the State of an unmounted component (which in this case will cause the please wait modal getting stuck forever). In this case it's safe doing it because the origin component is kept in the stack.

I'm leaving this PR unmerged for a while in case you want to review the last changes.

src/components/Delegation/PoolWarningModal.js Outdated Show resolved Hide resolved
@v-almonacid v-almonacid merged commit c507e19 into develop Apr 17, 2020
@v-almonacid v-almonacid deleted the v_almonacid/ch2389/warning-if-delegating-to-a-pool-in-the-blacklist branch April 17, 2020 17:29
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.

2 participants