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

Clear Personal Bank Account Onyx keys in componentWillUnmount #15679

Merged
merged 8 commits into from
Mar 21, 2023
4 changes: 3 additions & 1 deletion src/components/AddPlaidBankAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ class AddPlaidBankAccount extends React.Component {

componentDidMount() {
// If we're coming from Plaid OAuth flow then we need to reuse the existing plaidLinkToken
// If there is already a selected Plaid accountID then we don't need to trigger the Plaid flow
if ((this.props.receivedRedirectURI && this.props.plaidLinkOAuthToken)
|| !_.isEmpty(lodashGet(this.props.plaidData, 'bankAccounts'))
|| !_.isEmpty(lodashGet(this.props.plaidData, 'errors'))) {
|| !_.isEmpty(lodashGet(this.props.plaidData, 'errors'))
|| !_.isEmpty(this.props.selectedPlaidAccountID)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm do you know why we're re-entering this view in the first place? I wonder if the fix shouldn't happen outside of the view so this component doesn't get called.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For the issue #15197 we are entering via deep-linking, directly using the URL so it makes sense.

But for another issue, I am confused too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm do you know why we're re-entering this view in the first place?

My theory is that when the user clicks the Continue button on the PBA success page, because we clear ONYXKEYS.PERSONAL_BANK_ACCOUNT, shouldShowSuccess evaluates to false and the AddPlaidBankAccount component is mounted again.

But I'm not 100% why it only happens during wallet KYC and via deep-linking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know what you think, @nkuoch @Santhosh-Sellavel

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need to clear details here?

onButtonPress={() => {
BankAccounts.clearPersonalBankAccount();
Navigation.navigate(ROUTES.SETTINGS_PAYMENTS);

Does it affect anything else, if it needs to be cleared we can do it at componentWillUnmount

@MariaHCD or @nkuoch

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea. I think we can remove BankAccounts.clearPersonalBankAccount(); from onButtonPress. The original idea was to make sure it's cleared for any next setup, but we already call it in componentDidMount, so it's probably useless here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, nice catch, @Santhosh-Sellavel! I think it would make sense to call it in componentWillUnmount. We're also calling it at componentDidMount but maybe it makes more sense to just have it in componentWillUnmount just so that there isn't any outdated data in the Onyx keys once the PBA is added. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree let me know when changes are done!

return;
}

Expand Down