diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-05-06 12:08:58 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-05-06 12:08:58 -0400 |
commit | 0cfcf5c5decc89a8a8070272f92da0c0ae49693d (patch) | |
tree | ba2018c98116b80c33b3c33fcdece64e908bea72 /webapp | |
parent | d2f9fd52fe8b0da6f23775f242660329fcef6421 (diff) | |
download | chat-0cfcf5c5decc89a8a8070272f92da0c0ae49693d.tar.gz chat-0cfcf5c5decc89a8a8070272f92da0c0ae49693d.tar.bz2 chat-0cfcf5c5decc89a8a8070272f92da0c0ae49693d.zip |
Add separator between DMs on your team and not (#2910)
Diffstat (limited to 'webapp')
-rw-r--r-- | webapp/action_creators/websocket_actions.jsx | 10 | ||||
-rw-r--r-- | webapp/components/sidebar.jsx | 20 | ||||
-rw-r--r-- | webapp/stores/user_store.jsx | 10 | ||||
-rw-r--r-- | webapp/utils/constants.jsx | 1 |
4 files changed, 39 insertions, 2 deletions
diff --git a/webapp/action_creators/websocket_actions.jsx b/webapp/action_creators/websocket_actions.jsx index 0d4c76201..b208b4d33 100644 --- a/webapp/action_creators/websocket_actions.jsx +++ b/webapp/action_creators/websocket_actions.jsx @@ -141,6 +141,10 @@ function handleMessage(msg) { handleChannelDeletedEvent(msg); break; + case SocketEvents.DIRECT_ADDED: + handleDirectAddedEvent(msg); + break; + case SocketEvents.PREFERENCE_CHANGED: handlePreferenceChangedEvent(msg); break; @@ -201,9 +205,15 @@ function handlePostDeleteEvent(msg) { function handleNewUserEvent() { AsyncClient.getProfiles(); + AsyncClient.getDirectProfiles(); AsyncClient.getChannelExtraInfo(); } +function handleDirectAddedEvent(msg) { + AsyncClient.getChannel(msg.channel_id); + AsyncClient.getDirectProfiles(); +} + function handleUserAddedEvent(msg) { if (ChannelStore.getCurrentId() === msg.channel_id) { AsyncClient.getChannelExtraInfo(); diff --git a/webapp/components/sidebar.jsx b/webapp/components/sidebar.jsx index 71091f12b..29ad60acc 100644 --- a/webapp/components/sidebar.jsx +++ b/webapp/components/sidebar.jsx @@ -91,6 +91,7 @@ export default class Sidebar extends React.Component { const preferences = PreferenceStore.getCategory(Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW); const directChannels = []; + const directNonTeamChannels = []; for (const [name, value] of preferences) { if (value !== 'true') { continue; @@ -117,10 +118,15 @@ export default class Sidebar extends React.Component { directChannel.teammate_id = teammateId; directChannel.status = UserStore.getStatus(teammateId); - directChannels.push(directChannel); + if (UserStore.hasTeamProfile(teammateId)) { + directChannels.push(directChannel); + } else { + directNonTeamChannels.push(directChannel); + } } directChannels.sort(this.sortChannelsByDisplayName); + directNonTeamChannels.sort(this.sortChannelsByDisplayName); const tutorialStep = PreferenceStore.getInt(Preferences.TUTORIAL_STEP, UserStore.getCurrentId(), 999); @@ -130,6 +136,7 @@ export default class Sidebar extends React.Component { publicChannels, privateChannels, directChannels, + directNonTeamChannels, unreadCounts: JSON.parse(JSON.stringify(ChannelStore.getUnreadCounts())), showTutorialTip: tutorialStep === TutorialSteps.CHANNEL_POPOVER, currentTeam: TeamStore.getCurrent(), @@ -496,6 +503,15 @@ export default class Sidebar extends React.Component { return this.createChannelElement(channel, index, arr, this.handleLeaveDirectChannel); }); + const directMessageNonTeamItems = this.state.directNonTeamChannels.map((channel, index, arr) => { + return this.createChannelElement(channel, index, arr, this.handleLeaveDirectChannel); + }); + + let directDivider; + if (directMessageNonTeamItems.length !== 0) { + directDivider = <hr/>; + } + // update the favicon to show if there are any notifications if (this.lastBadgesActive !== this.badgesActive) { var link = document.createElement('link'); @@ -675,6 +691,8 @@ export default class Sidebar extends React.Component { </h4> </li> {directMessageItems} + {directDivider} + {directMessageNonTeamItems} {directMessageMore} </ul> </div> diff --git a/webapp/stores/user_store.jsx b/webapp/stores/user_store.jsx index 2d792fa17..8ae1e1404 100644 --- a/webapp/stores/user_store.jsx +++ b/webapp/stores/user_store.jsx @@ -114,6 +114,14 @@ class UserStoreClass extends EventEmitter { return this.getProfile(userId) != null; } + hasTeamProfile(userId) { + return this.getProfiles()[userId]; + } + + hasDirectProfile(userId) { + return this.getDirectProfiles()[userId]; + } + getProfile(userId) { if (userId === this.getCurrentId()) { return this.getCurrentUser(); @@ -194,7 +202,7 @@ class UserStoreClass extends EventEmitter { const currentUser = this.profiles[currentId]; if (currentUser) { if (currentId in this.profiles) { - delete this.profiles[currentId]; + Reflect.deleteProperty(this.profiles, currentId); } this.profiles = profiles; diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx index fb4086c7a..a505812f3 100644 --- a/webapp/utils/constants.jsx +++ b/webapp/utils/constants.jsx @@ -151,6 +151,7 @@ export default { POST_DELETED: 'post_deleted', CHANNEL_DELETED: 'channel_deleted', CHANNEL_VIEWED: 'channel_viewed', + DIRECT_ADDED: 'direct_added', NEW_USER: 'new_user', USER_ADDED: 'user_added', USER_REMOVED: 'user_removed', |