when a channel is update propagate the channel to everybody (#6677)

This commit is contained in:
Carlos Tadeu Panato Junior
2017-06-21 22:01:05 +02:00
committed by Christopher Speller
parent a9ef8b52aa
commit 1e84e931ec
4 changed files with 16 additions and 0 deletions

View File

@@ -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
}
}

View File

@@ -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"

View File

@@ -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) {

View File

@@ -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',