Problem: item counts don't update
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone Build is passing

Solution: re-enable updateChannelUnreadCount
This commit is contained in:
Peter Stuifzand 2022-04-17 00:09:26 +02:00
parent eba40a4eee
commit 8adfb56274
Signed by: peter
GPG Key ID: 374322D56E5209E8
2 changed files with 19 additions and 15 deletions

View File

@ -860,19 +860,22 @@ func (b *memoryBackend) channelAddItem(channel string, item microsub.Item) (bool
}
func (b *memoryBackend) updateChannelUnreadCount(channel string) error {
// tl := b.getTimeline(channel)
// unread, err := tl.Count()
// if err != nil {
// return err
// }
//
// currentCount := c.Unread.UnreadCount
// c.Unread = microsub.Unread{Type: microsub.UnreadCount, UnreadCount: unread}
//
// // Sent message to Server-Sent-Events
// if currentCount != unread {
// b.broker.Notifier <- sse.Message{Event: "new item in channel", Object: c}
// }
tl := b.getTimeline(channel)
unread, err := tl.Count()
if err != nil {
return err
}
var c microsub.Channel
c.UID = channel
currentCount := c.Unread.UnreadCount
c.Unread = microsub.Unread{Type: microsub.UnreadCount, UnreadCount: unread}
// Sent message to Server-Sent-Events
if currentCount != unread {
b.broker.Notifier <- sse.Message{Event: "new item in channel", Object: c}
}
return nil
}

View File

@ -225,10 +225,11 @@ func (p *postgresStream) Count() (int, error) {
if row == nil {
return 0, nil
}
var count int
err = row.Scan(&count)
if err != nil {
return -1, err
if err != nil && err == sql.ErrNoRows {
return 0, nil
}
return count, nil