fix: Remove the condition to only set new members in `get_members`
@@ -925,7 +925,15 @@ impl BaseClient {
for member in &members {
let member: SyncRoomMemberEvent = member.clone().into();
- if self.store.get_member_event(room_id, member.state_key()).await?.is_none() {
+ // TODO: All the actions in this loop used to be done only when the membership
+ // event was not in the store before. This was changed with the new room API,
+ // because e.g. leaving a room makes members events outdated and they need to be
+ // fetched by `get_members`. Therefore, they need to be overwritten here, even
+ // if they exist.
+ // However, this makes a new problem occur where setting the member events here
+ // potentially races with the sync.
+ // See <https://github.com/matrix-org/matrix-rust-sdk/issues/1205>.
+
#[cfg(feature = "e2e-encryption")]
match member.membership() {
MembershipState::Join | MembershipState::Invite => {
@@ -935,7 +943,6 @@ impl BaseClient {
}
ambiguity_cache.handle_event(&changes, room_id, &member).await?;
- }
if member.state_key() == member.sender() {
changes
