diff options
author | Christopher Speller <crspeller@gmail.com> | 2016-04-27 16:02:58 -0400 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-04-27 16:02:58 -0400 |
commit | fa807d8e436e87b8c1749ea54c293a15c67f7f29 (patch) | |
tree | 9557bb5342425dffd3606cb03f1378de5f5cc032 /webapp/action_creators | |
parent | d962e175f838817f4db060227cf8b5e2258b887c (diff) | |
download | chat-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.jsx | 40 |
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, + ); +} |