diff options
Diffstat (limited to 'webapp/utils')
-rw-r--r-- | webapp/utils/async_client.jsx | 8 | ||||
-rw-r--r-- | webapp/utils/utils.jsx | 29 |
2 files changed, 27 insertions, 10 deletions
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx index cc19baa7e..db0b2258c 100644 --- a/webapp/utils/async_client.jsx +++ b/webapp/utils/async_client.jsx @@ -1182,10 +1182,10 @@ export function addIncomingHook(hook, success, error) { } }, (err) => { - dispatchError(err, 'addIncomingHook'); - if (error) { error(err); + } else { + dispatchError(err, 'addIncomingHook'); } } ); @@ -1205,10 +1205,10 @@ export function addOutgoingHook(hook, success, error) { } }, (err) => { - dispatchError(err, 'addOutgoingHook'); - if (error) { error(err); + } else { + dispatchError(err, 'addOutgoingHook'); } } ); 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); |