Skip to content

Commit

Permalink
#58 make sure own user is always the first in the list (top left)
Browse files Browse the repository at this point in the history
  • Loading branch information
xeronimus@gmail.com authored and xeronimus@gmail.com committed Jun 20, 2020
1 parent 1a8df29 commit baf3882
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions client/app/components/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,25 @@ import User from './User';
/**
* The list of users (avatars) and their estimations.
*/
const Users = ({users}) => (
<div className="users">
{Object.values(users).map((user, index) => (
<User key={user.id} index={index} user={user} />
))}
</div>
);
const Users = ({users, ownUserId}) => {
const userArray = Object.values(users);
userArray.sort((uOne, uTwo) => (uOne.id === ownUserId ? -1 : uTwo.id === ownUserId ? 1 : 0));

return (
<div className="users">
{userArray.map((user, index) => (
<User key={user.id} index={index} user={user} />
))}
</div>
);
};

Users.propTypes = {
users: PropTypes.object
users: PropTypes.object,
ownUserId: PropTypes.string
};

export default connect((state) => ({
users: state.users
users: state.users,
ownUserId: state.userId
}))(Users);

0 comments on commit baf3882

Please sign in to comment.