summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-05 11:47:34 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-13 09:42:25 -0400
commit415f959614f6a3fd7fcb6551e32b722df2b015c5 (patch)
tree1eb990f41afcf9d1c57efadeed134c3754b3cd8e
parent4678794133d74c9ae018889e72106d5b0ce5da4b (diff)
downloadchat-415f959614f6a3fd7fcb6551e32b722df2b015c5.tar.gz
chat-415f959614f6a3fd7fcb6551e32b722df2b015c5.tar.bz2
chat-415f959614f6a3fd7fcb6551e32b722df2b015c5.zip
Made direct channels visible when receiving a message on one
-rw-r--r--web/react/components/sidebar.jsx12
1 files changed, 12 insertions, 0 deletions
diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index 449a3eaea..de353deb4 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -71,6 +71,7 @@ export default class Sidebar extends React.Component {
channelName = teammate.id + '__' + UserStore.getCurrentId();
}
+ let forceShow = false;
let channel = ChannelStore.getByName(channelName);
if (!channel) {
@@ -80,6 +81,11 @@ export default class Sidebar extends React.Component {
channel.last_post_at = 0;
channel.total_msg_count = 0;
channel.type = 'D';
+ } else {
+ const member = members[channel.id];
+ const msgCount = channel.total_msg_count - member.msg_count;
+
+ forceShow = currentId === channel.id || msgCount > 0;
}
channel.display_name = teammate.username;
@@ -88,6 +94,12 @@ export default class Sidebar extends React.Component {
if (preferences.some((preference) => (preference.alt_id === teammate.id && preference.value !== 'false'))) {
visibleDirectChannels.push(channel);
+ } else if (forceShow) {
+ // make sure that unread direct channels are visible
+ const preference = PreferenceStore.setPreferenceWithAltId('direct_channels', 'show_hide', teammate.id, 'true');
+ AsyncClient.setPreferences([preference]);
+
+ visibleDirectChannels.push(channel);
} else {
hiddenDirectChannels.push(channel);
}