Fix JS errors when receiving message when on no teams (#6533)

This commit is contained in:
Joram Wilander
2017-06-01 08:15:47 -04:00
committed by GitHub
parent 09e7ba23e3
commit f662d0d632
2 changed files with 16 additions and 33 deletions

View File

@@ -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 {

View File

@@ -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');
}
);
);
}
}