Skip to content

Commit

Permalink
hicli/sync: fix updating preview event rowid on redaction
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Mar 9, 2025
1 parent 7f80301 commit 0ed5dfc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/hicli/database/room.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/hicli/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 0ed5dfc

Please sign in to comment.