summaryrefslogtreecommitdiffstats
path: root/webapp/actions
diff options
context:
space:
mode:
authorBjörn Roland <bjoernr-de@users.noreply.github.com>2016-12-22 15:46:34 +0100
committerenahum <nahumhbl@gmail.com>2016-12-22 11:46:34 -0300
commit8a92908dad4f74ac3373d65a361594acb95cf1a0 (patch)
tree1bc822b1fea575f8555be123749a3ee96fcf1960 /webapp/actions
parent257a2234c431caf98abb0b9b1791672ae59a17fe (diff)
downloadchat-8a92908dad4f74ac3373d65a361594acb95cf1a0.tar.gz
chat-8a92908dad4f74ac3373d65a361594acb95cf1a0.tar.bz2
chat-8a92908dad4f74ac3373d65a361594acb95cf1a0.zip
#4697 Move Client.createChannel() in components to an action (#4855)
* #4697 Move instances of Client.createChannel() in components to an action
Diffstat (limited to 'webapp/actions')
-rw-r--r--webapp/actions/channel_actions.jsx36
1 files changed, 36 insertions, 0 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx
index 952c8ada3..204e6f9f1 100644
--- a/webapp/actions/channel_actions.jsx
+++ b/webapp/actions/channel_actions.jsx
@@ -275,3 +275,39 @@ export function updateChannelNotifyProps(data, success, error) {
}
);
}
+
+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);
+ }
+ }
+ );
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'createChannel');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}