diff options
-rw-r--r-- | webapp/actions/global_actions.jsx | 14 | ||||
-rw-r--r-- | webapp/actions/user_actions.jsx | 35 |
2 files changed, 16 insertions, 33 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx index 3c88a7013..a1b178d67 100644 --- a/webapp/actions/global_actions.jsx +++ b/webapp/actions/global_actions.jsx @@ -36,7 +36,7 @@ import store from 'stores/redux_store.jsx'; const dispatch = store.dispatch; const getState = store.getState; import {removeUserFromTeam} from 'mattermost-redux/actions/teams'; -import {viewChannel, getChannelStats, getMyChannelMember} from 'mattermost-redux/actions/channels'; +import {viewChannel, getChannelStats, getMyChannelMember, getChannelAndMyMember} from 'mattermost-redux/actions/channels'; export function emitChannelClickEvent(channel) { function userVisitedFakeChannel(chan, success, fail) { @@ -557,13 +557,13 @@ export function redirectUserToDefaultTeam() { redirect(teams[teamId].name, channel); } else if (channelId) { Client.setTeamId(teamId); - Client.getChannel( - channelId, + getChannelAndMyMember(channelId)(dispatch, getState).then( (data) => { - redirect(teams[teamId].name, data.channel.name); - }, - () => { - redirect(teams[teamId].name, 'town-square'); + if (data) { + redirect(teams[teamId].name, data.channel.name); + } else { + redirect(teams[teamId].name, 'town-square'); + } } ); } else { diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx index c8d848555..606dccdb8 100644 --- a/webapp/actions/user_actions.jsx +++ b/webapp/actions/user_actions.jsx @@ -48,6 +48,7 @@ import { import {getClientConfig, getLicenseConfig} from 'mattermost-redux/actions/general'; import {getTeamMembersByIds, getMyTeamMembers} from 'mattermost-redux/actions/teams'; +import {getChannelAndMyMember} from 'mattermost-redux/actions/channels'; export function loadMe(callback) { loadMeRedux()(dispatch, getState).then( @@ -276,21 +277,13 @@ export function loadNewDMIfNeeded(channelId) { if (channel) { checkPreference(channel); } else { - Client.getChannel( - channelId, + getChannelAndMyMember(channelId)(dispatch, getState).then( (data) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNEL, - channel: data.channel, - member: data.member - }); - - checkPreference(data.channel); - }, - (err) => { - AsyncClient.dispatchError(err, 'getChannel'); + if (data) { + checkPreference(data.channel); + } } - ); + ); } } @@ -308,21 +301,11 @@ export function loadNewGMIfNeeded(channelId) { if (channel) { checkPreference(); } else { - Client.getChannel( - channelId, - (data) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNEL, - channel: data.channel, - member: data.member - }); - + getChannelAndMyMember(channelId)(dispatch, getState).then( + () => { checkPreference(); - }, - (err) => { - AsyncClient.dispatchError(err, 'getChannel'); } - ); + ); } } |