summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-06-21 22:01:05 +0200
committerChristopher Speller <crspeller@gmail.com>2017-06-21 13:01:05 -0700
commit1e84e931ecdd9d72ed3825b6bc458eda3f5df667 (patch)
treebd17e61bea0378fd2cc21788b4322d8ac94158f3
parenta9ef8b52aa2ac1dfada58ae55252715c5cb32a84 (diff)
downloadchat-1e84e931ecdd9d72ed3825b6bc458eda3f5df667.tar.gz
chat-1e84e931ecdd9d72ed3825b6bc458eda3f5df667.tar.bz2
chat-1e84e931ecdd9d72ed3825b6bc458eda3f5df667.zip
when a channel is update propagate the channel to everybody (#6677)
-rw-r--r--app/channel.go5
-rw-r--r--model/websocket_message.go1
-rw-r--r--webapp/actions/websocket_actions.jsx9
-rw-r--r--webapp/utils/constants.jsx1
4 files changed, 16 insertions, 0 deletions
diff --git a/app/channel.go b/app/channel.go
index 84be8557b..794379369 100644
--- a/app/channel.go
+++ b/app/channel.go
@@ -281,6 +281,11 @@ func UpdateChannel(channel *model.Channel) (*model.Channel, *model.AppError) {
return nil, result.Err
} else {
InvalidateCacheForChannel(channel)
+
+ messageWs := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_UPDATED, "", channel.Id, "", nil)
+ messageWs.Add("channel", channel.ToJson())
+ Publish(messageWs)
+
return channel, nil
}
}
diff --git a/model/websocket_message.go b/model/websocket_message.go
index 623ed85bf..8c804a6f1 100644
--- a/model/websocket_message.go
+++ b/model/websocket_message.go
@@ -15,6 +15,7 @@ const (
WEBSOCKET_EVENT_POST_DELETED = "post_deleted"
WEBSOCKET_EVENT_CHANNEL_DELETED = "channel_deleted"
WEBSOCKET_EVENT_CHANNEL_CREATED = "channel_created"
+ WEBSOCKET_EVENT_CHANNEL_UPDATED = "channel_updated"
WEBSOCKET_EVENT_DIRECT_ADDED = "direct_added"
WEBSOCKET_EVENT_GROUP_ADDED = "group_added"
WEBSOCKET_EVENT_NEW_USER = "new_user"
diff --git a/webapp/actions/websocket_actions.jsx b/webapp/actions/websocket_actions.jsx
index 1aaecfb71..db301d539 100644
--- a/webapp/actions/websocket_actions.jsx
+++ b/webapp/actions/websocket_actions.jsx
@@ -186,6 +186,10 @@ function handleEvent(msg) {
handleChannelDeletedEvent(msg);
break;
+ case SocketEvents.CHANNEL_UPDATED:
+ handleChannelUpdatedEvent(msg);
+ break;
+
case SocketEvents.DIRECT_ADDED:
handleDirectAddedEvent(msg);
break;
@@ -358,6 +362,11 @@ function handleUserRemovedEvent(msg) {
}
}
+function handleChannelUpdatedEvent(msg) {
+ const channel = JSON.parse(msg.data.channel);
+ dispatch({type: ChannelTypes.RECEIVED_CHANNEL, data: channel});
+}
+
function handleUserUpdatedEvent(msg) {
const user = msg.data.user;
if (UserStore.getCurrentId() !== user.id) {
diff --git a/webapp/utils/constants.jsx b/webapp/utils/constants.jsx
index 986e1b758..9b18b52f9 100644
--- a/webapp/utils/constants.jsx
+++ b/webapp/utils/constants.jsx
@@ -222,6 +222,7 @@ export const SocketEvents = {
POST_DELETED: 'post_deleted',
CHANNEL_CREATED: 'channel_created',
CHANNEL_DELETED: 'channel_deleted',
+ CHANNEL_UPDATED: 'channel_updated',
CHANNEL_VIEWED: 'channel_viewed',
DIRECT_ADDED: 'direct_added',
NEW_USER: 'new_user',