summaryrefslogtreecommitdiffstats
path: root/webapp/action_creators
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-04-27 16:02:58 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-04-27 16:02:58 -0400
commitfa807d8e436e87b8c1749ea54c293a15c67f7f29 (patch)
tree9557bb5342425dffd3606cb03f1378de5f5cc032 /webapp/action_creators
parentd962e175f838817f4db060227cf8b5e2258b887c (diff)
downloadchat-fa807d8e436e87b8c1749ea54c293a15c67f7f29.tar.gz
chat-fa807d8e436e87b8c1749ea54c293a15c67f7f29.tar.bz2
chat-fa807d8e436e87b8c1749ea54c293a15c67f7f29.zip
Fixing permalinks to channels your not a memeber of (#2805)
Diffstat (limited to 'webapp/action_creators')
-rw-r--r--webapp/action_creators/global_actions.jsx40
1 files changed, 29 insertions, 11 deletions
diff --git a/webapp/action_creators/global_actions.jsx b/webapp/action_creators/global_actions.jsx
index bf1d82aee..335c20219 100644
--- a/webapp/action_creators/global_actions.jsx
+++ b/webapp/action_creators/global_actions.jsx
@@ -128,21 +128,31 @@ export function emitInitialLoad(callback) {
);
}
+export function doFocusPost(channelId, postId, data) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_FOCUSED_POST,
+ postId,
+ post_list: data
+ });
+ AsyncClient.getChannels(true);
+ AsyncClient.getChannelExtraInfo(channelId);
+ AsyncClient.getPostsBefore(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS);
+ AsyncClient.getPostsAfter(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS);
+}
+
export function emitPostFocusEvent(postId) {
AsyncClient.getChannels(true);
- Client.getPostById(
+ Client.getPermalinkTmp(
postId,
(data) => {
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_FOCUSED_POST,
- postId,
- post_list: data
- });
-
- AsyncClient.getChannelExtraInfo(data.channel_id);
-
- AsyncClient.getPostsBefore(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS);
- AsyncClient.getPostsAfter(postId, 0, Constants.POST_FOCUS_CONTEXT_RADIUS);
+ if (!data) {
+ return;
+ }
+ const channelId = data.posts[data.order[0]].channel_id;
+ doFocusPost(channelId, postId, data);
+ },
+ () => {
+ browserHistory.push('/error?message=' + encodeURIComponent(Utils.localizeMessage('permalink.error.access', 'Permalink belongs to a channel you do not have access to')));
}
);
}
@@ -431,3 +441,11 @@ export function emitUserLoggedOutEvent(redirectTo) {
}
);
}
+
+export function emitJoinChannelEvent(channel, success, failure) {
+ Client.joinChannel(
+ channel.id,
+ success,
+ failure,
+ );
+}