diff --git a/sync3/lists.go b/sync3/lists.go index fc773b0..555c077 100644 --- a/sync3/lists.go +++ b/sync3/lists.go @@ -156,6 +156,18 @@ func (s *InternalRequestLists) Get(listKey string) *FilteredSortableRooms { return s.lists[listKey] } +// ListKeys returns a copy of the list keys currently tracked by this +// InternalRequestLists struct, in no particular order. Outside of test code, you +// probably don't want to call this---you probably have the set of list keys tracked +// elsewhere in the application. +func (s *InternalRequestLists) ListKeys() []string { + keys := make([]string, len(s.lists)) + for listKey, _ := range s.lists { + keys = append(keys, listKey) + } + return keys +} + // ListsByVisibleRoomIDs builds a map from room IDs to a slice of list names. Keys are // all room IDs that are currently visible in at least one sliding window. Values are // the names of all lists (in no particular order) in which the given room ID is diff --git a/sync3/lists_test.go b/sync3/lists_test.go index c3c7a98..6917c29 100644 --- a/sync3/lists_test.go +++ b/sync3/lists_test.go @@ -31,6 +31,10 @@ func addRooms(list *sync3.InternalRequestLists, n int) { for i := 0; i < n; i++ { next := roomCounter.Add(1) messageTimestamp := uint64(timestamp.Add(time.Duration(next) * time.Minute).UnixMilli()) + lastInterestedEventTimestamps := make(map[string]uint64) + for _, listKey := range list.ListKeys() { + lastInterestedEventTimestamps[listKey] = messageTimestamp + } list.SetRoom(sync3.RoomConnMetadata{ RoomMetadata: internal.RoomMetadata{ RoomID: fmt.Sprintf("!%d:benchmark", next), @@ -41,7 +45,7 @@ func addRooms(list *sync3.InternalRequestLists, n int) { UserRoomData: caches.UserRoomData{ IsDM: next%10 == 0, }, - LastInterestedEventTimestamps: make(map[string]uint64), + LastInterestedEventTimestamps: lastInterestedEventTimestamps, }) } }