forked from Mirrors/gomuks
hicli/database: fix FillReactionCounts
This commit is contained in:
parent
728db4d650
commit
9d96ed1b12
1 changed files with 6 additions and 3 deletions
|
@ -156,14 +156,17 @@ func (eq *EventQuery) UpdateEncryptedContent(ctx context.Context, evt *Event) er
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EventQuery) FillReactionCounts(ctx context.Context, roomID id.RoomID, events []*Event) error {
|
func (eq *EventQuery) FillReactionCounts(ctx context.Context, roomID id.RoomID, events []*Event) error {
|
||||||
eventIDs := make([]id.EventID, 0)
|
eventIDs := make([]id.EventID, 0, len(events))
|
||||||
eventMap := make(map[id.EventID]*Event)
|
eventMap := make(map[id.EventID]*Event)
|
||||||
for i, evt := range events {
|
for _, evt := range events {
|
||||||
if evt.Reactions == nil {
|
if evt.Reactions == nil {
|
||||||
eventIDs[i] = evt.ID
|
eventIDs = append(eventIDs, evt.ID)
|
||||||
eventMap[evt.ID] = evt
|
eventMap[evt.ID] = evt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(eventIDs) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
result, err := eq.GetReactions(ctx, roomID, eventIDs...)
|
result, err := eq.GetReactions(ctx, roomID, eventIDs...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue