Merge pull request #2575 from hmhealey/plt2480

PLT-2478/PLT-2480 Fixing direct channels in sidebar
This commit is contained in:
Joram Wilander
2016-03-30 11:16:49 -04:00
2 changed files with 11 additions and 6 deletions

View File

@@ -238,7 +238,9 @@ export default class Sidebar extends React.Component {
});
}
handleLeaveDirectChannel(channel) {
handleLeaveDirectChannel(e, channel) {
e.preventDefault();
if (!this.isLeaving.get(channel.id)) {
this.isLeaving.set(channel.id, true);
@@ -258,7 +260,7 @@ export default class Sidebar extends React.Component {
}
if (channel.id === this.state.activeId) {
browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square');
browserHistory.push('/' + this.state.currentTeam.name + '/channels/town-square');
}
}
@@ -422,7 +424,7 @@ export default class Sidebar extends React.Component {
overlay={removeTooltip}
>
<span
onClick={() => handleClose(channel)}
onClick={(e) => handleClose(e, channel)}
className='btn-close'
>
{'×'}

View File

@@ -1259,12 +1259,15 @@ export function windowHeight() {
}
export function openDirectChannelToUser(user, successCb, errorCb) {
AsyncClient.savePreference(
Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW,
user.id,
'true'
);
const channelName = this.getDirectChannelName(UserStore.getCurrentId(), user.id);
let channel = ChannelStore.getByName(channelName);
const preference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DIRECT_CHANNEL_SHOW, user.id, 'true');
AsyncClient.savePreferences([preference]);
if (channel) {
if ($.isFunction(successCb)) {
successCb(channel, true);