Skip to content

Conversation

@wonjun-opensource
Copy link
Contributor

Issue #823

Disconnecting your wallet in MetaMask resets your balance, but not your pending yield or lifetime earnings
and
I had the opposite experience today: my balance remained but the other two numbers were removed.

occurred because we were waiting until the fetch queries were completed in AccountListener after a wallet is disconnected.

A good way to reproduce some of this behavior is to connect the wallet first. Then, open Chrome DevTools -> Network -> set it to "offline" to force fetch queries to fail. And then, disconnect the wallet and see that "Pending Yield" still has the value set on the header.

A better approach is to update ContractStore and set ContractStore.walletConnected = false when useWeb3React tells us that the account is no longer active as soon as the user disconnects their wallet.

@wonjun-opensource wonjun-opensource self-assigned this Sep 25, 2022
@wonjun-opensource wonjun-opensource changed the title Update ContractStore in AccountListener when the user disconnects the wallet Update ContractStore.walletConnected in AccountListener when the user disconnects the wallet Sep 25, 2022
Copy link
Collaborator

@shahthepro shahthepro left a comment

Choose a reason for hiding this comment

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

Looks good to me, LGTM

}
const response = await fetch(endpoint)
if (!response.ok) {
if (!response || !response.ok) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Could use the shorthand !response?.ok

Copy link
Member

@sparrowDom sparrowDom left a comment

Choose a reason for hiding this comment

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

thanks for this LGTM

@franckc
Copy link

franckc commented Jan 20, 2023

@sparrowDom Can we merge this PR?

@sparrowDom
Copy link
Member

yes thanks for nudge @franckc

@sparrowDom sparrowDom merged commit f119492 into master Jan 20, 2023
@sparrowDom sparrowDom deleted the data-reset-when-wallet-disconnects branch January 20, 2023 13:17
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.

5 participants