forked from Mirrors/gomuks
hicli/sync: create implicit read receipts for own events
This commit is contained in:
parent
0742feb365
commit
497e507783
1 changed files with 14 additions and 1 deletions
|
@ -666,11 +666,24 @@ func (h *HiClient) processStateAndTimeline(
|
|||
timelineIDs := make([]database.EventRowID, len(timeline.Events))
|
||||
readUpToIndex := -1
|
||||
for i := len(timeline.Events) - 1; i >= 0; i-- {
|
||||
if slices.Contains(newOwnReceipts, timeline.Events[i].ID) {
|
||||
evt := timeline.Events[i]
|
||||
isRead := slices.Contains(newOwnReceipts, evt.ID)
|
||||
isOwnEvent := evt.Sender == h.Account.UserID
|
||||
if isRead || isOwnEvent {
|
||||
readUpToIndex = i
|
||||
// Reset unread counts if we see our own read receipt in the timeline.
|
||||
// It'll be updated with new unreads (if any) at the end.
|
||||
updatedRoom.UnreadCounts = database.UnreadCounts{}
|
||||
if !isRead {
|
||||
receipts = append(receipts, &database.Receipt{
|
||||
RoomID: room.ID,
|
||||
UserID: h.Account.UserID,
|
||||
ReceiptType: event.ReceiptTypeRead,
|
||||
EventID: evt.ID,
|
||||
Timestamp: jsontime.UM(time.UnixMilli(evt.Timestamp)),
|
||||
})
|
||||
newOwnReceipts = append(newOwnReceipts, evt.ID)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue