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: close batch flow when removing last draft #2453

Merged
merged 3 commits into from
Aug 29, 2023
Merged

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Aug 28, 2023

What it solves

Resolves #2428

How this PR fixes it

If the batch confirmation flow is open, it is now closed when the last draft is removed via the sidebar.

How to test it

Batch transaction(s) and enter the confirmation flow. Whilst in the flow, remove the last draft from the sidebar and observe the confirmation flow close. It should not close other flows that may be open under the sidebar.

Screenshots

close-batch

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@github-actions
Copy link

github-actions bot commented Aug 28, 2023

Branch preview

✅ Deploy successful!

https://close_batch_flow--walletweb.review-wallet-web.5afe.dev

@github-actions
Copy link

github-actions bot commented Aug 28, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

setTxFlow(undefined)
}
},
[deleteTx, batchTxs, setTxFlow],
Copy link
Member

Choose a reason for hiding this comment

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

I know React recommends using event handlers but I would do this in an effect instead.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a benefit of doing this in an effect over adding it to the onDelete handler?

Copy link
Member

@katspaugh katspaugh Aug 28, 2023

Choose a reason for hiding this comment

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

On delete is probably more robust. But at the same time deleting a tx and closing a modal are two completely different actions. Closing the modal is a side effect of having nothing to display. A matter of taste in the end, imperative vs declarative.

const shouldExitFlow = !!txFlow && batchTxs.length === 0
useEffect(() => {
if (shouldExitFlow) {
setTxFlow(undefined)
Copy link
Member

Choose a reason for hiding this comment

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

Can we somehow couple this to the user action i.e. add it to the deleteTx call instead of having it in a useEffect?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Btw can there be a case when there’s some other tx flow open, not a batch modal?

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw can there be a case when there’s some other tx flow open, not a batch modal?

I've updated this accordingly.

@francovenica
Copy link
Contributor

Looks good to me

I created a batched tx with a couple of tx inside. Clicked "Confirm batch" to go the "batch tx creation", deleted all the transaction and as I deleted the last one the form closed and the page was redirected to the dashboard
I made sure that this only happens with the "Batch tx creation" and not with other random transaction being executed.

@iamacook iamacook merged commit 2f6ec89 into dev Aug 29, 2023
9 checks passed
@iamacook iamacook deleted the close-batch-flow branch August 29, 2023 06:46
@github-actions github-actions bot locked and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Batching] Remove tx while in the form
4 participants