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

MM-28833 Remove computed details from getChannel selector #6794

Merged
merged 5 commits into from
Oct 28, 2020

Conversation

hmhealey
Copy link
Member

As I mentioned earlier this week, getChannel is problematic because its a selector that takes an argument without being behind a factory function, so if you have two or more components both using it, they'll constantly be overwriting each others' results, leading to those components re-rendering constantly. The main reason that this causes problems is that getChannel returns a new object each time for DMs and GMs because it adds on some additional derived fields such as the dynamic display_name for DM and GM channels. On the current version of master, this leads to things like parts of the new sidebar and all of the RHS re-rendering constantly.

I changed getChannel to be a plain function that doesn't compute any data so that it can be re-used easily wherever we don't need the computed fields, and I've used makeGetChannel to generate one-off selectors for everywhere that does need that data.

Ticket Link

https://mattermost.atlassian.net/browse/MM-28833

Related Pull Requests

mattermost/mattermost-redux#1257

@hmhealey hmhealey added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Oct 14, 2020
@@ -53,7 +53,6 @@ function makeMapStateToProps() {
return {
lastViewedAt,
channelLoading,
channel,
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 isn't actually used by the component

@@ -27,11 +26,10 @@ function makeMapStateToProps() {
const selected = getSelectedPost(state);
const socketStatus = getSocketStatus(state);

let channel = null;
const channel = getSelectedChannel(state);
Copy link
Member Author

Choose a reason for hiding this comment

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

We can get the selected channel directly from the store instead of having to infer it from the selected post to simplify things slightly

@hmhealey hmhealey added the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Oct 14, 2020
Copy link
Contributor

@nevyangelova nevyangelova left a comment

Choose a reason for hiding this comment

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

Thanks! Ran with your redux change and it does rerender less 🎉

@hmhealey hmhealey requested review from sudheerDev and removed request for deanwhillier October 19, 2020 17:47
@hmhealey hmhealey added Setup Cloud Test Server Setup a test server using Mattermost Cloud and removed Setup Cloud Test Server Setup a test server using Mattermost Cloud labels Oct 22, 2020
@mm-cloud-bot mm-cloud-bot removed the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Oct 22, 2020
@hanzei hanzei added the Setup Cloud Test Server Setup a test server using Mattermost Cloud label Oct 22, 2020
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.

Thank you @hmhealey
Tested, looks good to merge.

  • Verified DM & GM headers, DMs in channels switcher, channel names in RHS and search results and GM channel names in desktop notifications.

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

Test server destroyed

@mm-cloud-bot
Copy link

Test server creation failed. See the logs for more information.

@hmhealey hmhealey removed the Do Not Merge/Awaiting PR Awaiting another pull request before merging (e.g. server changes) label Oct 28, 2020
@hmhealey hmhealey merged commit 7d3af58 into master Oct 28, 2020
@hmhealey hmhealey deleted the MM-28833_get-channel branch October 28, 2020 18:49
@amyblais amyblais added this to the v5.30.0 milestone Oct 28, 2020
@amyblais amyblais added Changelog/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation labels Nov 16, 2020
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/Not Needed Does not require a changelog entry Docs/Not Needed Does not require documentation
Projects
None yet
7 participants