From ff741740eebceb43b1d69b13d97ae7eed2aa32d1 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 13 Feb 2017 09:27:28 -0500 Subject: Increase performance when receiving messages (#5375) --- app/channel.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/channel.go b/app/channel.go index fcd4e166d..194a43f69 100644 --- a/app/channel.go +++ b/app/channel.go @@ -844,7 +844,15 @@ func SearchChannelsUserNotIn(teamId string, userId string, term string) (*model. } func ViewChannel(view *model.ChannelView, teamId string, userId string, clearPushNotifications bool) *model.AppError { - channelIds := []string{view.ChannelId} + if err := SetActiveChannel(userId, view.ChannelId); err != nil { + return err + } + + channelIds := []string{} + + if len(view.ChannelId) > 0 { + channelIds = append(channelIds, view.ChannelId) + } var pchan store.StoreChannel if len(view.PrevChannelId) > 0 { @@ -855,6 +863,10 @@ func ViewChannel(view *model.ChannelView, teamId string, userId string, clearPus } } + if len(channelIds) == 0 { + return nil + } + uchan := Srv.Store.Channel().UpdateLastViewedAt(channelIds, userId) if pchan != nil { @@ -871,10 +883,6 @@ func ViewChannel(view *model.ChannelView, teamId string, userId string, clearPus return result.Err } - message := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_CHANNEL_VIEWED, teamId, "", userId, nil) - message.Add("channel_id", view.ChannelId) - go Publish(message) - return nil } -- cgit v1.2.3-1-g7c22