summaryrefslogtreecommitdiffstats
path: root/web/react/components/sidebar.jsx
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-07 11:34:29 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-13 09:42:26 -0400
commit097d236f437b0c5af167cd383c6ee4c3ee45f495 (patch)
treeed81272f94f8706b5ddf25badde6d660df7a657c /web/react/components/sidebar.jsx
parented6b2cd164b249c67db0e0421cc78964450240c9 (diff)
downloadchat-097d236f437b0c5af167cd383c6ee4c3ee45f495.tar.gz
chat-097d236f437b0c5af167cd383c6ee4c3ee45f495.tar.bz2
chat-097d236f437b0c5af167cd383c6ee4c3ee45f495.zip
Fixed edge cases with leaving a direct channel while viewing that channel
Diffstat (limited to 'web/react/components/sidebar.jsx')
-rw-r--r--web/react/components/sidebar.jsx15
1 files changed, 10 insertions, 5 deletions
diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index 2619798eb..54edb3c31 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -33,6 +33,8 @@ export default class Sidebar extends React.Component {
this.handleLeaveDirectChannel = this.handleLeaveDirectChannel.bind(this);
this.createChannelElement = this.createChannelElement.bind(this);
+ this.isLeaving = new Map();
+
const state = this.getStateFromStores();
state.modal = '';
state.loadingDMChannel = -1;
@@ -85,7 +87,8 @@ export default class Sidebar extends React.Component {
const member = members[channel.id];
const msgCount = channel.total_msg_count - member.msg_count;
- forceShow = currentId === channel.id || msgCount > 0;
+ // always show a channel if either it is the current one or if it is unread, but it is not currently being left
+ forceShow = (currentId === channel.id || msgCount > 0) && !this.isLeaving.get(channel.id);
}
channel.display_name = teammate.username;
@@ -93,8 +96,10 @@ export default class Sidebar extends React.Component {
channel.status = UserStore.getStatus(teammate.id);
if (preferences.some((preference) => (preference.alt_id === teammate.id && preference.value !== 'false'))) {
+ console.log(teammate.id + " is visible");
visibleDirectChannels.push(channel);
} else if (forceShow) {
+ console.log(teammate.id + " needs to be visible");
// make sure that unread direct channels are visible
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
Constants.Preferences.NAME_SHOW, teammate.id, 'true');
@@ -304,18 +309,18 @@ export default class Sidebar extends React.Component {
}
handleLeaveDirectChannel(channel) {
- if (!channel.leaving) {
- channel.leaving = true;
+ if (!this.isLeaving.get(channel.id)) {
+ this.isLeaving.set(channel.id, true);
const preference = PreferenceStore.setPreferenceWithAltId(Constants.Preferences.CATEGORY_DIRECT_CHANNELS,
Constants.Preferences.NAME_SHOW, channel.teammate_id, 'false');
AsyncClient.setPreferences(
[preference],
() => {
- channel.leaving = false;
+ this.isLeaving.set(channel.id, false);
},
() => {
- channel.leaving = false;
+ this.isLeaving.set(channel.id, false);
}
);