diff options
author | enahum <nahumhbl@gmail.com> | 2017-02-27 17:41:12 -0300 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-02-27 15:41:12 -0500 |
commit | 48f97a5a2a0754bfc0e639db7cce03943e990e32 (patch) | |
tree | 74d6a48d467d245e62f1e3c526a9abf9413c71a9 /webapp/actions/channel_actions.jsx | |
parent | 72de977c522465bc2ee044cd4a26baf666f299a3 (diff) | |
download | chat-48f97a5a2a0754bfc0e639db7cce03943e990e32.tar.gz chat-48f97a5a2a0754bfc0e639db7cce03943e990e32.tar.bz2 chat-48f97a5a2a0754bfc0e639db7cce03943e990e32.zip |
PLT-5653 Fix Create channel does not show in another device (#5548)
Diffstat (limited to 'webapp/actions/channel_actions.jsx')
-rw-r--r-- | webapp/actions/channel_actions.jsx | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx index 3528b4480..5f41d127d 100644 --- a/webapp/actions/channel_actions.jsx +++ b/webapp/actions/channel_actions.jsx @@ -335,27 +335,34 @@ export function createChannel(channel, success, error) { Client.createChannel( channel, (data) => { - Client.getChannel( - data.id, - (data2) => { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECEIVED_CHANNEL, - channel: data2.channel, - member: data2.channel - }); - - if (success) { - success(data2); - } - }, - (err) => { - AsyncClient.dispatchError(err, 'getChannel'); - - if (error) { - error(err); - } + const existing = ChannelStore.getChannelById(data.id); + if (existing) { + if (success) { + success({channel: existing}); } - ); + } else { + Client.getChannel( + data.id, + (data2) => { + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_CHANNEL, + channel: data2.channel, + member: data2.channel + }); + + if (success) { + success(data2); + } + }, + (err) => { + AsyncClient.dispatchError(err, 'getChannel'); + + if (error) { + error(err); + } + } + ); + } }, (err) => { AsyncClient.dispatchError(err, 'createChannel'); |