summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-13 09:27:28 -0500
committerCorey Hulen <corey@hulen.com>2017-02-13 09:27:28 -0500
commitff741740eebceb43b1d69b13d97ae7eed2aa32d1 (patch)
tree0f795cea935a72997bf3618ceaf3b0513d5e8096 /app
parentfac85b676eafb20b5f70db1805006d64889606ff (diff)
downloadchat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.tar.gz
chat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.tar.bz2
chat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.zip
Increase performance when receiving messages (#5375)
Diffstat (limited to 'app')
-rw-r--r--app/channel.go18
1 files changed, 13 insertions, 5 deletions
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
}