summaryrefslogtreecommitdiffstats
path: root/webapp/root.jsx
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/root.jsx
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/root.jsx')
-rw-r--r--webapp/root.jsx26
1 files changed, 15 insertions, 11 deletions
diff --git a/webapp/root.jsx b/webapp/root.jsx
index 1e9adea16..e90d3fdc5 100644
--- a/webapp/root.jsx
+++ b/webapp/root.jsx
@@ -187,17 +187,11 @@ function onPermalinkEnter(nextState) {
GlobalActions.emitPostFocusEvent(postId);
}
-function onChannelEnter(nextState, replace) {
- doChannelChange(nextState, replace);
+function onChannelEnter(nextState, replace, callback) {
+ doChannelChange(nextState, replace, callback);
}
-function onChannelChange(prevState, nextState, replace) {
- if (prevState.params.channel !== nextState.params.channel) {
- doChannelChange(nextState, replace);
- }
-}
-
-function doChannelChange(state, replace) {
+function doChannelChange(state, replace, callback) {
let channel;
if (state.location.query.fakechannel) {
channel = JSON.parse(state.location.query.fakechannel);
@@ -207,11 +201,22 @@ function doChannelChange(state, replace) {
channel = ChannelStore.getMoreByName(state.params.channel);
}
if (!channel) {
- replace('/');
+ Client.joinChannelByName(
+ state.params.channel,
+ (data) => {
+ GlobalActions.emitChannelClickEvent(data);
+ callback();
+ },
+ () => {
+ replace('/');
+ callback();
+ }
+ );
return;
}
}
GlobalActions.emitChannelClickEvent(channel);
+ callback();
}
function renderRootComponent() {
@@ -311,7 +316,6 @@ function renderRootComponent() {
<Route
path='channels/:channel'
onEnter={onChannelEnter}
- onChange={onChannelChange}
components={{
sidebar: Sidebar,
center: ChannelView