mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
GetLastInterestedEventTimestamp: return early
on the happy path
This commit is contained in:
parent
4f69909f8b
commit
f5d588678d
@ -52,16 +52,17 @@ type RoomConnMetadata struct {
|
||||
|
||||
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
|
||||
if ok {
|
||||
return ts
|
||||
}
|
||||
// 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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user