-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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: fix network switch on dapp #30211
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
Builds ready [0e1dcb8]
Page Load Metrics (1900 ± 139 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [1ab8ebe]
Page Load Metrics (1687 ± 52 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
if (chainId && Object.keys(tokenNetworkFilter).length === 1) { | ||
this.preferencesController.setPreference('tokenNetworkFilter', { | ||
[chainId]: true, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm what is this condition doing here?
Object.keys(tokenNetworkFilter).length === 1
this related to portfolio view (you are only viewing tokens from 1 network, so not in portfolio view).
this.preferencesController.setPreference(... {[chainId]: true})
this is to swap the tokens I'm interested in to the newly selected network?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if I am in portfolio view, and I switch networks from a dapp, I stay in portfolio view?
But what if it is a not popular network?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what we're doing is checking if the chainId is defined and whether the tokenNetworkFilter corresponds to the current network—something like { '0x1': true }. Then, if we switch from Ethereum to BNB in the dapp, we would update this to { '0x38': true }.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep nice. I've ran the branch and validated the fix.
This is a little confusing though, in the future do you think it would be worth moving this (token filter list) logic in a shared location/module/utilities? We can discuss this later.
Builds ready [0bb5bc9]
Page Load Metrics (1622 ± 48 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
Related issues
Fixes: #30149
Manual testing steps
Screenshots/Recordings
Before
After
fixed.mov
Pre-merge author checklist
Pre-merge reviewer checklist