Lazy-loading fixes (#2646)
* Use existing current room state if we have it * Don't dedupe before applying the history vis filter * Revert "Don't dedupe before applying the history vis filter" This reverts commitd27c4a0874
. * Revert "Use existing current room state if we have it" This reverts commit5819b4a7ce
. * Tweaks
This commit is contained in:
parent
804653e551
commit
ec16c944eb
|
@ -560,14 +560,13 @@ func (p *PDUStreamProvider) lazyLoadMembers(
|
||||||
// If this is a gapped incremental sync, we still want this membership
|
// If this is a gapped incremental sync, we still want this membership
|
||||||
isGappedIncremental := limited && incremental
|
isGappedIncremental := limited && incremental
|
||||||
// We want this users membership event, keep it in the list
|
// We want this users membership event, keep it in the list
|
||||||
_, ok := timelineUsers[event.Sender()]
|
stateKey := *event.StateKey()
|
||||||
wantMembership := ok || isGappedIncremental
|
if _, ok := timelineUsers[stateKey]; ok || isGappedIncremental {
|
||||||
if wantMembership {
|
|
||||||
newStateEvents = append(newStateEvents, event)
|
newStateEvents = append(newStateEvents, event)
|
||||||
if !includeRedundant {
|
if !includeRedundant {
|
||||||
p.lazyLoadCache.StoreLazyLoadedUser(device, roomID, event.Sender(), event.EventID())
|
p.lazyLoadCache.StoreLazyLoadedUser(device, roomID, stateKey, event.EventID())
|
||||||
}
|
}
|
||||||
delete(timelineUsers, event.Sender())
|
delete(timelineUsers, stateKey)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newStateEvents = append(newStateEvents, event)
|
newStateEvents = append(newStateEvents, event)
|
||||||
|
@ -578,17 +577,16 @@ func (p *PDUStreamProvider) lazyLoadMembers(
|
||||||
wantUsers = append(wantUsers, userID)
|
wantUsers = append(wantUsers, userID)
|
||||||
}
|
}
|
||||||
// Query missing membership events
|
// Query missing membership events
|
||||||
memberships, err := p.DB.GetStateEventsForRoom(ctx, roomID, &gomatrixserverlib.StateFilter{
|
filter := gomatrixserverlib.DefaultStateFilter()
|
||||||
Limit: 100,
|
filter.Senders = &wantUsers
|
||||||
Senders: &wantUsers,
|
filter.Types = &[]string{gomatrixserverlib.MRoomMember}
|
||||||
Types: &[]string{gomatrixserverlib.MRoomMember},
|
memberships, err := p.DB.GetStateEventsForRoom(ctx, roomID, &filter)
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return stateEvents, err
|
return stateEvents, err
|
||||||
}
|
}
|
||||||
// cache the membership events
|
// cache the membership events
|
||||||
for _, membership := range memberships {
|
for _, membership := range memberships {
|
||||||
p.lazyLoadCache.StoreLazyLoadedUser(device, roomID, membership.Sender(), membership.EventID())
|
p.lazyLoadCache.StoreLazyLoadedUser(device, roomID, *membership.StateKey(), membership.EventID())
|
||||||
}
|
}
|
||||||
stateEvents = append(newStateEvents, memberships...)
|
stateEvents = append(newStateEvents, memberships...)
|
||||||
return stateEvents, nil
|
return stateEvents, nil
|
||||||
|
|
Loading…
Reference in a new issue