Use unread count for channels

This commit is contained in:
Peter Stuifzand 2018-04-10 20:35:16 +02:00
parent e24c01e781
commit fc4400a3c8
3 changed files with 10 additions and 6 deletions

View File

@ -400,7 +400,11 @@ func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) {
log.Println(item)
if c, e := b.Channels[channel]; e {
c.Unread = true
unread, err := redis.Int(conn.Do("ZCARD", zchannelKey))
if err != nil {
log.Printf("error while getting length of channel %s: %v\n", channelKey, err)
}
c.Unread = unread
b.Channels[channel] = c
}
}

View File

@ -28,10 +28,10 @@ type NullBackend struct {
// ChannelsGetList gets no channels
func (b *NullBackend) ChannelsGetList() []microsub.Channel {
return []microsub.Channel{
microsub.Channel{UID: "0000", Name: "default", Unread: false},
microsub.Channel{UID: "0001", Name: "notifications", Unread: false},
microsub.Channel{UID: "1000", Name: "Friends", Unread: false},
microsub.Channel{UID: "1001", Name: "Family", Unread: false},
microsub.Channel{UID: "0000", Name: "default", Unread: 0},
microsub.Channel{UID: "0001", Name: "notifications", Unread: 0},
microsub.Channel{UID: "1000", Name: "Friends", Unread: 0},
microsub.Channel{UID: "1001", Name: "Family", Unread: 0},
}
}

View File

@ -34,7 +34,7 @@ type Channel struct {
// UID is a unique id for the channel
UID string `json:"uid"`
Name string `json:"name"`
Unread bool `json:"unread"`
Unread int `json:"unread"`
}
type Card struct {