Fix the failing E2E test

This commit is contained in:
David Robertson 2023-05-24 18:41:13 +01:00
parent 039a1621ad
commit 471c0a26eb
No known key found for this signature in database
GPG Key ID: 903ECE108A39DEDD
2 changed files with 18 additions and 2 deletions

View File

@ -49,3 +49,19 @@ type RoomConnMetadata struct {
// https://github.com/matrix-org/matrix-react-sdk/blob/526645c79160ab1ad4b4c3845de27d51263a405e/docs/room-list-store.md#tag-sorting-algorithm-recent
LastInterestedEventTimestamps map[string]uint64
}
func (r *RoomConnMetadata) GetLastInterestedEventTimestamp(listKey string) uint64 {
ts, ok := r.LastInterestedEventTimestamps[listKey]
if !ok {
// SetRoom is responsible for maintaining LastInterestedEventTimestamps.
// However, if a brand-new list appears and we don't call SetRoom, we need to
// ensure we hand back a sensible timestamp. So: use the (current)
// LastMessageTimestamp as a fallback.
ts = r.LastMessageTimestamp
// Write this value into the map. If we don't and only uninteresting events
// arrive after, the fallback value will have jumped ahead despite nothing of
// interest happening.
r.LastInterestedEventTimestamps[listKey] = ts
}
return ts
}

View File

@ -147,10 +147,10 @@ func (s *SortableRooms) comparatorSortByName(i, j int) int {
func (s *SortableRooms) comparatorSortByRecency(i, j int) int {
ri, rj := s.resolveRooms(i, j)
if ri.LastInterestedEventTimestamps[s.listKey] == rj.LastInterestedEventTimestamps[s.listKey] {
if ri.GetLastInterestedEventTimestamp(s.listKey) == rj.GetLastInterestedEventTimestamp(s.listKey) {
return 0
}
if ri.LastInterestedEventTimestamps[s.listKey] > rj.LastInterestedEventTimestamps[s.listKey] {
if ri.GetLastInterestedEventTimestamp(s.listKey) > rj.GetLastInterestedEventTimestamp(s.listKey) {
return 1
}
return -1