Join channel with permalink to public channel you're not in (#6795)

Этот коммит содержится в:
Joram Wilander
2017-06-29 12:25:18 -04:00
коммит произвёл Corey Hulen
родитель 02019f154d
Коммит a3ece09262

Просмотреть файл

@@ -37,7 +37,7 @@ const getState = store.getState;
import {Client4} from 'mattermost-redux/client'; import {Client4} from 'mattermost-redux/client';
import {removeUserFromTeam} from 'mattermost-redux/actions/teams'; import {removeUserFromTeam} from 'mattermost-redux/actions/teams';
import {viewChannel, getChannelStats, getMyChannelMember, getChannelAndMyMember, createDirectChannel} from 'mattermost-redux/actions/channels'; import {viewChannel, getChannelStats, getMyChannelMember, getChannelAndMyMember, createDirectChannel, joinChannel} from 'mattermost-redux/actions/channels';
import {getPostThread} from 'mattermost-redux/actions/posts'; import {getPostThread} from 'mattermost-redux/actions/posts';
export function emitChannelClickEvent(channel) { export function emitChannelClickEvent(channel) {
@@ -101,7 +101,7 @@ export function emitChannelClickEvent(channel) {
} }
} }
export function doFocusPost(channelId, postId, data) { export async function doFocusPost(channelId, postId, data) {
AppDispatcher.handleServerAction({ AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_FOCUSED_POST, type: ActionTypes.RECEIVED_FOCUSED_POST,
postId, postId,
@@ -115,6 +115,11 @@ export function doFocusPost(channelId, postId, data) {
channelId channelId
}); });
const member = getState().entities.channels.myMembers[channelId];
if (member == null) {
await joinChannel(UserStore.getCurrentId(), null, channelId)(dispatch, getState);
}
loadChannelsForCurrentUser(); loadChannelsForCurrentUser();
getChannelStats(channelId)(dispatch, getState); getChannelStats(channelId)(dispatch, getState);
} }
@@ -125,11 +130,11 @@ export function emitPostFocusEvent(postId, onSuccess) {
(data) => { (data) => {
if (data) { if (data) {
const channelId = data.posts[data.order[0]].channel_id; const channelId = data.posts[data.order[0]].channel_id;
doFocusPost(channelId, postId, data); doFocusPost(channelId, postId, data).then(() => {
if (onSuccess) {
if (onSuccess) { onSuccess();
onSuccess(); }
} });
} else { } else {
let link = `${TeamStore.getCurrentTeamRelativeUrl()}/channels/`; let link = `${TeamStore.getCurrentTeamRelativeUrl()}/channels/`;
const channel = ChannelStore.getCurrent(); const channel = ChannelStore.getCurrent();