summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-06-29 12:25:18 -0400
committerCorey Hulen <corey@hulen.com>2017-06-29 09:25:18 -0700
commita3ece092626ac4c1d19123a18a5d1118af056f4d (patch)
treea6b61209dfaa54f8121ff7fc9ff29aa62cd70ad9 /webapp
parent02019f154d7baf42fc6463278bf318f83b34cd29 (diff)
downloadchat-a3ece092626ac4c1d19123a18a5d1118af056f4d.tar.gz
chat-a3ece092626ac4c1d19123a18a5d1118af056f4d.tar.bz2
chat-a3ece092626ac4c1d19123a18a5d1118af056f4d.zip
Join channel with permalink to public channel you're not in (#6795)
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/global_actions.jsx19
1 files changed, 12 insertions, 7 deletions
diff --git a/webapp/actions/global_actions.jsx b/webapp/actions/global_actions.jsx
index a154d556d..1108e3834 100644
--- a/webapp/actions/global_actions.jsx
+++ b/webapp/actions/global_actions.jsx
@@ -37,7 +37,7 @@ const getState = store.getState;
import {Client4} from 'mattermost-redux/client';
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';
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({
type: ActionTypes.RECEIVED_FOCUSED_POST,
postId,
@@ -115,6 +115,11 @@ export function doFocusPost(channelId, postId, data) {
channelId
});
+ const member = getState().entities.channels.myMembers[channelId];
+ if (member == null) {
+ await joinChannel(UserStore.getCurrentId(), null, channelId)(dispatch, getState);
+ }
+
loadChannelsForCurrentUser();
getChannelStats(channelId)(dispatch, getState);
}
@@ -125,11 +130,11 @@ export function emitPostFocusEvent(postId, onSuccess) {
(data) => {
if (data) {
const channelId = data.posts[data.order[0]].channel_id;
- doFocusPost(channelId, postId, data);
-
- if (onSuccess) {
- onSuccess();
- }
+ doFocusPost(channelId, postId, data).then(() => {
+ if (onSuccess) {
+ onSuccess();
+ }
+ });
} else {
let link = `${TeamStore.getCurrentTeamRelativeUrl()}/channels/`;
const channel = ChannelStore.getCurrent();