diff options
Diffstat (limited to 'web/react')
-rw-r--r-- | web/react/components/more_direct_channels.jsx | 15 | ||||
-rw-r--r-- | web/react/components/sidebar.jsx | 15 | ||||
-rw-r--r-- | web/react/stores/preference_store.jsx | 1 | ||||
-rw-r--r-- | web/react/utils/client.jsx | 1 |
4 files changed, 11 insertions, 21 deletions
diff --git a/web/react/components/more_direct_channels.jsx b/web/react/components/more_direct_channels.jsx index ed9c6fc58..96c08c441 100644 --- a/web/react/components/more_direct_channels.jsx +++ b/web/react/components/more_direct_channels.jsx @@ -82,21 +82,6 @@ export default class MoreDirectChannels extends React.Component { ); }; } - } else { - if (channel.id === ChannelStore.getCurrentId()) { - active = 'active'; - } - - if (channel.unread) { - badge = <span className='badge pull-right small'>{channel.unread}</span>; - titleClass = 'unread-title'; - } - - handleClick = function clickHandler(e) { - e.preventDefault(); - utils.switchChannel(channel); - $(React.findDOMNode(self.refs.modal)).modal('hide'); - }; } return ( 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); } ); diff --git a/web/react/stores/preference_store.jsx b/web/react/stores/preference_store.jsx index d731e7d27..8101452ed 100644 --- a/web/react/stores/preference_store.jsx +++ b/web/react/stores/preference_store.jsx @@ -39,7 +39,6 @@ class PreferenceStoreClass extends EventEmitter { } getAllPreferences() { - console.log('getting preferences'); // eslint-disable-line no-console return new Map(BrowserStore.getItem('preferences', [])); } diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index 2134dc0f5..4e3505ad2 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -1159,6 +1159,7 @@ export function setPreferences(preferences, success, error) { $.ajax({ url: '/api/v1/preferences/set', dataType: 'json', + contentType: 'application/json', type: 'POST', data: JSON.stringify(preferences), success, |