From fa807d8e436e87b8c1749ea54c293a15c67f7f29 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Wed, 27 Apr 2016 16:02:58 -0400 Subject: Fixing permalinks to channels your not a memeber of (#2805) --- webapp/root.jsx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'webapp/root.jsx') 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() {