-
Notifications
You must be signed in to change notification settings - Fork 2.7k
MM-41955 Reduce useless changes to user state #9833
Conversation
@@ -181,10 +180,6 @@ export default class Root extends React.PureComponent { | |||
} | |||
|
|||
onConfigLoaded = () => { | |||
if (isDevMode()) { | |||
enableDevModeFeatures(); |
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.
This added a warning when trying to access a non-existent .length
property of a Set or Map which lodash does in isEqual
to try to identify the type of object. Since we have TypeScript now that will warn us if we do that by mistake, that warning isn't needed any more anyway.
@@ -458,25 +454,31 @@ function profilesNotInGroup(state: RelationOneToMany<Group, UserProfile> = {}, a | |||
} | |||
} | |||
|
|||
function saveToState<T>(state: Record<string, T>, key: string, value: T): Record<string, T> { |
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.
can we think of a better name, because its not actually saving but merging 0/5 🤔
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.
Maybe addToState
? I just put this helper here, but it seems like it'd be really helpful throughout all the redux state. I'm pretty sure we could use these helpers in Joram's PR too, but I don't want to change too much else right now.
/e2e-tests |
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 - one non-blocking comment
/e2e-test |
Triggering e2e testing with options: |
Successfully triggered e2e testing! |
E2E report shows many failures (35+) related to autocomplete |
/e2e-test |
Those should be fixed now. Turns out the autocomplete was throwing an error which broke most of those tests |
/update-branch |
Updating, will restart e2es afterwards, the cycle failed to start yesterday. |
/e2e-test |
Triggering e2e testing with options: |
Successfully triggered e2e testing! |
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.
Thanks @hmhealey
Tested, looks good to merge.
- E2E report looks good, no PR related failures.
Test server destroyed |
/cherry-pick release-6.3 |
Cherry pick is scheduled. |
Error trying doing the automated Cherry picking. Please do this manually
|
@hmhealey Needs a manual cherry-pick. |
* MM-41955 Reduce useless changes to user profile state * MM-41955 Reduce useless changes to user statuses state * Remove helper that prints errors when using lodash's isEqual * Remove tests involving enableDevModeFeatures * Handle test that uses an array instead of a Set * Rename saveToState to addToState * Fix autocomplete Co-authored-by: Mattermod <[email protected]>
* MM-41955 Reduce useless changes to user profile state * MM-41955 Reduce useless changes to user statuses state * Remove helper that prints errors when using lodash's isEqual * Remove tests involving enableDevModeFeatures * Handle test that uses an array instead of a Set * Rename saveToState to addToState * Fix autocomplete Co-authored-by: Mattermod <[email protected]>
* MM-41955 Reduce useless changes to user profile state * MM-41955 Reduce useless changes to user statuses state * Remove helper that prints errors when using lodash's isEqual * Remove tests involving enableDevModeFeatures * Handle test that uses an array instead of a Set * Rename saveToState to addToState * Fix autocomplete Co-authored-by: Mattermod <[email protected]> Co-authored-by: Mattermod <[email protected]>
As discussed, we want to reduce accidental state changes caused by reducers returning new state objects which are identical to the the previous values. This does that for all of the most used parts of users state (
profiles
,statuses
,profilesInChannel
). I didn't bother doing it with a lot of the other ones likeprofilesInTeam
orprofilesNotInGroup
since they're only really used in the System Console and modals for managing users in channels/teams/groups, so they won't impact general performance as much. Ideally, I'd actually like to get those ones out of redux entirely, but that's future work.Ticket Link
https://mattermost.atlassian.net/browse/MM-41955
Release Note