Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

MM-41955 Reduce useless changes to user state #9833

Merged
merged 9 commits into from
Mar 1, 2022

Conversation

hmhealey
Copy link
Member

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 like profilesInTeam or profilesNotInGroup 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

Improved performance of code for storing users in web app

@hmhealey hmhealey added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Feb 17, 2022
@hmhealey hmhealey added this to the v6.3.0 milestone Feb 17, 2022
@@ -181,10 +180,6 @@ export default class Root extends React.PureComponent {
}

onConfigLoaded = () => {
if (isDevMode()) {
enableDevModeFeatures();
Copy link
Member Author

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> {
Copy link
Member

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 🤔

Copy link
Member Author

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.

@hmhealey
Copy link
Member Author

/e2e-tests

Copy link
Member

@jwilander jwilander left a 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

@jwilander jwilander removed the 2: Dev Review Requires review by a core commiter label Feb 17, 2022
@hmhealey hmhealey removed the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Feb 17, 2022
@hmhealey hmhealey removed this from the v6.3.0 milestone Feb 17, 2022
@hmhealey
Copy link
Member Author

/e2e-test

@mattermod
Copy link
Contributor

Triggering e2e testing with options:
<nil>

@mattermod
Copy link
Contributor

@jgilliam17 jgilliam17 added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Feb 25, 2022
@jgilliam17
Copy link
Contributor

E2E report shows many failures (35+) related to autocomplete
Mention autocomplete is showing a loading spinner e.g. for no results and also when match is found
Screen Shot 2022-02-24 at 10 29 06 PM

@hmhealey
Copy link
Member Author

/e2e-test

@hmhealey
Copy link
Member Author

Those should be fixed now. Turns out the autocomplete was throwing an error which broke most of those tests

@jgilliam17
Copy link
Contributor

/update-branch

@jgilliam17
Copy link
Contributor

Updating, will restart e2es afterwards, the cycle failed to start yesterday.

@jgilliam17
Copy link
Contributor

/e2e-test

@mattermod
Copy link
Contributor

Triggering e2e testing with options:
<nil>

@mattermod
Copy link
Contributor

Copy link
Contributor

@jgilliam17 jgilliam17 left a 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.

@jgilliam17 jgilliam17 added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Mar 1, 2022
@mm-cloud-bot
Copy link

Test server destroyed

@jgilliam17 jgilliam17 merged commit 707676c into master Mar 1, 2022
@jgilliam17 jgilliam17 deleted the MM-41955_reduce-user-state-changes branch March 1, 2022 20:42
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Mar 2, 2022
@amyblais
Copy link
Member

amyblais commented Mar 7, 2022

/cherry-pick release-6.3

@mattermod
Copy link
Contributor

Cherry pick is scheduled.

@mattermod
Copy link
Contributor

Error trying doing the automated Cherry picking. Please do this manually

+++ Updating remotes...
Fetching upstream
Failed to add the RSA host key for IP address '140.82.114.4' to the list of known hosts (/app/.ssh/known_hosts).
From github.com:mattermost/mattermost-webapp
   2255783b2..773c6da47  master      -> upstream/master
   2bd0eb01e..be55b969e  release-6.4 -> upstream/release-6.4
   df6d2aefd..e4224d8eb  release-6.5 -> upstream/release-6.5
Fetching origin
Failed to add the RSA host key for IP address '140.82.113.4' to the list of known hosts (/app/.ssh/known_hosts).
+++ Updating remotes done...
+++ Creating local branch automated-cherry-pick-of-mattermost-webapp-#9833-upstream-release-6.3-1646663560
Switched to a new branch 'automated-cherry-pick-of-mattermost-webapp-#9833-upstream-release-6.3-1646663560'
Branch 'automated-cherry-pick-of-mattermost-webapp-#9833-upstream-release-6.3-1646663560' set up to track remote branch 'release-6.3' from 'upstream'.

+++ About to attempt cherry pick of PR #9833 with merge commit 707676cc3b860e53e2a2134cb4ecfab0e93fefd5.

error: could not apply 707676cc3... MM-41955 Reduce useless changes to user state (#9833)
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

+++ Conflicts detected:

UU components/root/root.jsx
UU components/root/root.test.jsx
UU packages/mattermost-redux/src/reducers/entities/users.ts
Aborting.

+++ Aborting in-progress git cherry-pick.

+++ Returning you to the master branch and cleaning up.

@amyblais amyblais added the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Mar 7, 2022
@amyblais
Copy link
Member

amyblais commented Mar 7, 2022

@hmhealey Needs a manual cherry-pick.

hmhealey added a commit that referenced this pull request Mar 7, 2022
* 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]>
hmhealey added a commit that referenced this pull request Mar 7, 2022
* 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]>
hmhealey added a commit that referenced this pull request Mar 7, 2022
* 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]>
@amyblais amyblais added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone Docs/Not Needed Does not require documentation release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants