summaryrefslogtreecommitdiffstats
path: root/model/channel_list.go
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-10-27 12:24:30 -0300
committerHarrison Healey <harrisonmhealey@gmail.com>2016-10-27 11:24:30 -0400
commitf82667f3b86202dafff3a2a4ea56aec74c80316d (patch)
tree3785d9502505be528706e41b993a834c7bc00338 /model/channel_list.go
parent14ce471311fee2830be3cbd3a90179015f513719 (diff)
downloadchat-f82667f3b86202dafff3a2a4ea56aec74c80316d.tar.gz
chat-f82667f3b86202dafff3a2a4ea56aec74c80316d.tar.bz2
chat-f82667f3b86202dafff3a2a4ea56aec74c80316d.zip
PLT-4430 improve slow channel switching (#4331)
* PLT-4430 improve slow channel switching * Update client side unit tests * Convert getChannelsUnread to getMyChannelMembers and address other feedback * Pull channel members on websocket reconnect
Diffstat (limited to 'model/channel_list.go')
-rw-r--r--model/channel_list.go35
1 files changed, 5 insertions, 30 deletions
diff --git a/model/channel_list.go b/model/channel_list.go
index 49ba384a2..7a46de45d 100644
--- a/model/channel_list.go
+++ b/model/channel_list.go
@@ -8,15 +8,11 @@ import (
"io"
)
-type ChannelList struct {
- Channels []*Channel `json:"channels"`
- Members map[string]*ChannelMember `json:"members"`
-}
+type ChannelList []*Channel
func (o *ChannelList) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
+ if b, err := json.Marshal(o); err != nil {
+ return "[]"
} else {
return string(b)
}
@@ -28,7 +24,7 @@ func (o *ChannelList) Etag() string {
var t int64 = 0
var delta int64 = 0
- for _, v := range o.Channels {
+ for _, v := range *o {
if v.LastPostAt > t {
t = v.LastPostAt
id = v.Id
@@ -39,30 +35,9 @@ func (o *ChannelList) Etag() string {
id = v.Id
}
- member := o.Members[v.Id]
-
- if member != nil {
- max := v.LastPostAt
- if v.UpdateAt > max {
- max = v.UpdateAt
- }
-
- delta += max - member.LastViewedAt
-
- if member.LastViewedAt > t {
- t = member.LastViewedAt
- id = v.Id
- }
-
- if member.LastUpdateAt > t {
- t = member.LastUpdateAt
- id = v.Id
- }
-
- }
}
- return Etag(id, t, delta, len(o.Channels))
+ return Etag(id, t, delta, len(*o))
}
func ChannelListFromJson(data io.Reader) *ChannelList {