diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-04-04 12:24:12 -0400 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2016-04-04 12:24:12 -0400 |
commit | 2bdab516b293d97f9797039e84f9d04656d2134d (patch) | |
tree | cf53b8f94f4f3d7ec1d697457c9847009035c058 /webapp/utils | |
parent | 2bb9332467f54ed6e2bc39e088c1268a61b24b6e (diff) | |
parent | 5f3111e8809ccc4fe32cc2958da5a47fd9c09bef (diff) | |
download | chat-2bdab516b293d97f9797039e84f9d04656d2134d.tar.gz chat-2bdab516b293d97f9797039e84f9d04656d2134d.tar.bz2 chat-2bdab516b293d97f9797039e84f9d04656d2134d.zip |
Merge pull request #2625 from mattermost/plt-2502
PLT-2502 Fxing some channel changing issues
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/utils.jsx | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 3b7583f15..399dd0985 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -3,7 +3,6 @@ import $ from 'jquery'; import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; -import * as GlobalActions from 'action_creators/global_actions.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import UserStore from 'stores/user_store.jsx'; import LocalizationStore from 'stores/localization_store.jsx'; @@ -168,7 +167,7 @@ export function notifyMe(title, body, channel) { notification.onclick = () => { window.focus(); if (channel) { - GlobalActions.emitChannelClickEvent(channel); + browserHistory.push(getTeamURLNoOriginFromAddressBar() + '/channels/' + channel.name); } else { browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square'); } @@ -1216,6 +1215,10 @@ export function getTeamURLFromAddressBar() { return window.location.origin + '/' + window.location.pathname.split('/')[1]; } +export function getTeamURLNoOriginFromAddressBar() { + return '/' + window.location.pathname.split('/')[1]; +} + export function getShortenedTeamURL() { const teamURL = getTeamURLFromAddressBar(); if (teamURL.length > 35) { @@ -1261,10 +1264,24 @@ export function openDirectChannelToUser(user, successCb, errorCb) { channel, user.id, (data) => { - AsyncClient.getChannel(data.id); - if ($.isFunction(successCb)) { - successCb(data, false); - } + Client.getChannel( + data.id, + (data2, textStatus, xhr) => { + if (xhr.status === 304 || !data2) { + return; + } + + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_CHANNEL, + channel: data2.channel, + member: data2.member + }); + + if ($.isFunction(successCb)) { + successCb(data2.channel, false); + } + } + ); }, () => { browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/' + channelName); |