-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Correctly detect changes to background state #8435
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Builds ready [dab86df]
|
rekmarks
previously approved these changes
Apr 28, 2020
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.
LGTM!
rekmarks
reviewed
Apr 28, 2020
whymarrh
previously approved these changes
Apr 28, 2020
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.
LGTM!
Changes to the background state were being detected in the `update` event handler in `ui/index.js` that receives state updates from the background. However this doesn't catch every update; some state changes are received by the UI in-between these `update` events. The background `getState` function is callable directly from the UI, and many action creators call it via `forceUpdateMetamaskState` to update the `metamask` state immediately without waiting for the next `update` event. These state updates skip this change detection in `ui/index.js`. For example, if a 3Box state restoration resulted in a `currentLocale` change, and then a `forceUpdateMetamaskState` call completed before the next `update `event was received, then `updateCurrentLocale` wouldn't be called, and the `locale` store would not be updated correctly with the localized messages for the new locale. We now check for background state changes in the `updateMetamaskState` action creator. All `metamask` state updates go through this function, so we aren't missing any changes anymore.
Gudahtt
force-pushed
the
fix-background-state-change-detection
branch
from
April 28, 2020 12:53
dab86df
to
35bec8d
Compare
Builds ready [35bec8d]
Page Load Metrics (599 ± 14 ms)
|
whymarrh
approved these changes
Apr 28, 2020
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.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes to the background state were being detected in the
update
event handler inui/index.js
that receives state updates from the background. However this doesn't catch every update; some state changes are received by the UI in-between theseupdate
events.The background
getState
function is callable directly from the UI, and many action creators call it viaforceUpdateMetamaskState
to update themetamask
state immediately without waiting for the nextupdate
event. These state updates skip this change detection inui/index.js
.For example, if a 3Box state restoration resulted in a
currentLocale
change, and then aforceUpdateMetamaskState
call completed before the nextupdate
event was received, thenupdateCurrentLocale
wouldn't be called, and thelocale
store would not be updated correctly with the localized messages for the new locale.We now check for background state changes in the
updateMetamaskState
action creator. Allmetamask
state updates go through this function, so we aren't missing any changes anymore.