Use boolean unread
This commit is contained in:
parent
faa685e291
commit
a2cd294b80
|
@ -368,11 +368,18 @@ func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) {
|
|||
return
|
||||
}
|
||||
|
||||
_, err = b.Redis.Do("SADD", channelKey, itemKey)
|
||||
added, err := redis.Int64(b.Redis.Do("SADD", channelKey, itemKey))
|
||||
if err != nil {
|
||||
log.Printf("error while adding item %s to channel %s for redis: %v\n", itemKey, channelKey, err)
|
||||
return
|
||||
}
|
||||
|
||||
if added > 0 {
|
||||
if c, e := b.Channels[channel]; e {
|
||||
c.Unread = true
|
||||
b.Channels[channel] = c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type redisItem struct {
|
||||
|
|
|
@ -28,10 +28,10 @@ type NullBackend struct {
|
|||
// ChannelsGetList gets no channels
|
||||
func (b *NullBackend) ChannelsGetList() []microsub.Channel {
|
||||
return []microsub.Channel{
|
||||
microsub.Channel{"0000", "default", 0},
|
||||
microsub.Channel{"0001", "notifications", 0},
|
||||
microsub.Channel{"1000", "Friends", 0},
|
||||
microsub.Channel{"1001", "Family", 0},
|
||||
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},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ type Channel struct {
|
|||
// UID is a unique id for the channel
|
||||
UID string `json:"uid"`
|
||||
Name string `json:"name"`
|
||||
Unread int `json:"unread"`
|
||||
Unread bool `json:"unread"`
|
||||
}
|
||||
|
||||
type Author struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user