hicli/sync: fix updating preview event rowid on redaction

This commit is contained in:
Tulir Asokan 2025-03-09 18:12:34 +02:00
parent 7f80301276
commit 0ed5dfcc12
2 changed files with 3 additions and 3 deletions

View file

@ -80,7 +80,7 @@ const (
AND (type IN ('m.room.message', 'm.sticker')
OR (type = 'm.room.encrypted'
AND decrypted_type IN ('m.room.message', 'm.sticker')))
AND relation_type <> 'm.replace'
AND (relation_type IS NULL OR relation_type <> 'm.replace')
AND redacted_by IS NULL
ORDER BY timestamp DESC
LIMIT 1
@ -215,7 +215,7 @@ func (r *Room) CheckChangesAndCopyInto(other *Room) (hasChanges bool) {
hasChanges = true
other.HasMemberList = true
}
if r.PreviewEventRowID > other.PreviewEventRowID {
if r.PreviewEventRowID != 0 {
other.PreviewEventRowID = r.PreviewEventRowID
hasChanges = true
}

View file

@ -785,7 +785,7 @@ func (h *HiClient) processStateAndTimeline(
return fmt.Errorf("failed to get relation target of redaction target: %w", err)
}
}
if updatedRoom.PreviewEventRowID == dbEvt.RowID {
if updatedRoom.PreviewEventRowID == dbEvt.RowID || (updatedRoom.PreviewEventRowID == 0 && room.PreviewEventRowID == dbEvt.RowID) {
updatedRoom.PreviewEventRowID = 0
recalculatePreviewEvent = true
}