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

[PLT-7409] Channel Member List: show status icon and sort by user's status #421

Merged
merged 3 commits into from
Jan 9, 2018
Merged

Conversation

saturninoabril
Copy link
Member

@saturninoabril saturninoabril commented Dec 6, 2017

Summary

Show status icon and sort by user's status (in the order of online > away > offline > dnd) to the following components:

  • MemberListChannel
  • PopoverListMembers (though not specifically mentioned in the ticket)

@jasonblais @esethna You might want to check this out if according to ticket specs. (I'm not really sure about the coverage). Also not sure if this should be for v4.5 as stated in Jira ticket.

Ticket Link

Jira ticket: PLT-7409

Checklist

[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]

  • Ran make check-style to check for style errors (required for all pull requests)
  • Ran make test to ensure unit and component tests passed
  • Has UI changes

@saturninoabril saturninoabril added 1: PM Review Requires review by a product manager 2: Dev Review Requires review by a core commiter labels Dec 6, 2017
@saturninoabril saturninoabril added this to the v4.6.0 milestone Dec 6, 2017
@saturninoabril saturninoabril modified the milestones: v4.6.0, v4.5.0 Dec 6, 2017
actionUserProps[user.id] = {
channel: this.props.channel,
teamMember: teamMembers[user.id],
channelMember: channelMembers[user.id]
};
}
}

usersToDisplay.sort((a, b) => {
return UserStatusesWeight[a.status] - UserStatusesWeight[b.status] || Utils.sortUsersByDisplayName(a, b);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand this - is it some kind of type coercion trick? It looks like you're subtracting the weighted values of the two users' statuses, and if that results in zero, we know that zero is falsy, so evaluate the OR condition, which sorts by name?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it's short-circuit evaluation. Your subsequent description is what I intend to do which I think works fine as I expected.

const status = UserStore.getStatus(member.id);
return {...member, status};
}).sort((a, b) => {
return UserStatusesWeight[a.status] - UserStatusesWeight[b.status] || Utils.sortUsersByDisplayName(a, b);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this sorting be generalized somewhere so that we aren't duplicating the code in the two components?

utils/utils.jsx Outdated
const bName = displayUsernameForUser(b);

return aName.localeCompare(bName);
}
Copy link
Contributor

@MusikPolice MusikPolice Dec 6, 2017

Choose a reason for hiding this comment

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

Perhaps accept two user objects here, and do all the sorting, including the status weighting, so that the components can just call this function? If you do that, you could easily write unit tests for this function as well, so we'd know that it doesn't break in the future.

@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Dec 6, 2017
@jasonblais jasonblais modified the milestones: v4.5.0, v4.6.0 Dec 6, 2017
@saturninoabril saturninoabril removed the Setup Old Test Server Triggers the creation of a test server label Dec 7, 2017
@mattermost mattermost deleted a comment from mattermod Dec 7, 2017
@mattermost mattermost deleted a comment from mattermod Dec 7, 2017
@mattermost mattermost deleted a comment from mattermod Dec 7, 2017
@saturninoabril
Copy link
Member Author

@MusikPolice updated PR per comments. Also added unit tests.

@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Dec 11, 2017
@@ -144,14 +145,18 @@ export default class MemberListChannel extends React.Component {
const user = users[i];

if (teamMembers[user.id] && channelMembers[user.id] && user.delete_at === 0) {
usersToDisplay.push(user);
const status = UserStore.getStatus(user.id);
Copy link
Member

@jwilander jwilander Dec 11, 2017

Choose a reason for hiding this comment

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

We shouldn't be using anything not in props or state to render. We should pull the statuses when we set the users in state or we should rewrite this component to be more redux friendly and pass it in as props

actionUserProps[user.id] = {
channel: this.props.channel,
teamMember: teamMembers[user.id],
channelMember: channelMembers[user.id]
};
}
}

usersToDisplay.sort(Utils.sortUsersByStatusAndDisplayName);
Copy link
Member

Choose a reason for hiding this comment

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

We should probably look into moving a bunch of this logic out of the render function if possible. It's possible that we'll render multiple times without the usersToDisplay changing, so rebuilding and sorting, and setting the result to state (or props even) might be worthwhile here. I'm only 1/5 on this though, it's going a bit beyond the scope of the ticket but if a user list is 1000+ in length this could potentially help performance a lot

Turning it into a selector would be even better (though more work)

const bName = Utils.displayUsernameForUser(b);
if (this.props.members && teamMembers) {
const sortedMembers = this.props.members.map((member) => {
const status = UserStore.getStatus(member.id);
Copy link
Member

Choose a reason for hiding this comment

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

Same issue here, needs to be in state or props if it's used for rendering

Copy link
Contributor

@esethna esethna left a comment

Choose a reason for hiding this comment

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

@saturninoabril it looks like the status icon component is incorrectly positioned and sized as compared to the center channel or LHS header profile icons:

image

Other than that it looks good, it will be for 4.6.

@esethna esethna added the Awaiting Submitter Action Blocked on the author label Dec 12, 2017
@saturninoabril
Copy link
Member Author

@jwilander @esethna Thanks! I'll address your comments.

@esethna
Copy link
Contributor

esethna commented Dec 22, 2017

@saturninoabril let me know if you have any questions about the items I brought up?

@jasonblais jasonblais mentioned this pull request Jan 2, 2018
1 task
@jasonblais
Copy link
Contributor

Hey @saturninoabril, wondering if there's a chance we'd be able to get this in for v4.6? Would be a nice UX improvement.

@saturninoabril
Copy link
Member Author

@jasonblais Kindly check whether the comments made by @esethna is satisfied. Also I've made some CSS change that @asaadmahmood might need to take a look.

@jwilander I initially tried to make use of selector but it's taking so long on me. That's why I ended up just moving some of the logics out of render function.

@saturninoabril saturninoabril removed the 2: Dev Review Requires review by a core commiter label Jan 4, 2018
@mattermost mattermost deleted a comment from mattermod Jan 8, 2018
@mattermost mattermost deleted a comment from mattermod Jan 8, 2018
@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Jan 8, 2018
@jasonblais
Copy link
Contributor

Thanks! Position looks good.

At the moment, the order is online/away/offline/dnd. Have asked @esethna to confirm whether that's the expected order for DND status.

@esethna esethna added 2: Dev Review Requires review by a core commiter and removed 1: PM Review Requires review by a product manager Setup Old Test Server Triggers the creation of a test server labels Jan 8, 2018
Copy link
Contributor

@esethna esethna left a comment

Choose a reason for hiding this comment

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

DND below offline makes sense since the real time notifications are disabled. Thanks guys!

@mattermost mattermost deleted a comment from mattermod Jan 8, 2018
@mattermost mattermost deleted a comment from mattermod Jan 8, 2018
@mattermost mattermost deleted a comment from mattermod Jan 8, 2018
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.

Alright, I'm OK with it since it's not introducing any imports of the flux stores but these components would be much cleaner if they were using redux for everything

@jwilander jwilander added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Jan 9, 2018
@jwilander
Copy link
Member

@saturninoabril after a rebase it should be good to merge

@saturninoabril
Copy link
Member Author

I'll merge this first and then will try to convert the components using redux. Thanks!

@saturninoabril saturninoabril merged commit 7b02ac5 into mattermost:master Jan 9, 2018
@saturninoabril saturninoabril deleted the PLT-7409 branch January 12, 2018 17:25
@amyblais amyblais added Changelog/Done Required changelog entry has been written Docs/Not Needed Does not require documentation labels Feb 1, 2018
@lindalumitchell lindalumitchell added the Tests/Done Release tests have been written label Feb 2, 2018
@amyblais amyblais added Changelog/Done Required changelog entry has been written and removed Changelog/Done Required changelog entry has been written labels Feb 6, 2018
hmhealey pushed a commit that referenced this pull request Aug 28, 2020
* Add typing selector based on channelId and postId

* changing getUsersTyping... selector to makeGetUsersTyping...
hmhealey pushed a commit that referenced this pull request Mar 17, 2021
* Add typing selector based on channelId and postId

* changing getUsersTyping... selector to makeGetUsersTyping...
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 Docs/Not Needed Does not require documentation Tests/Done Release tests have been written
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants