summaryrefslogtreecommitdiffstats
path: root/webapp/actions/channel_actions.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/actions/channel_actions.jsx')
-rw-r--r--webapp/actions/channel_actions.jsx47
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');