fix(rooms): start a room's roster from the member list, not the join echo
soulfind tells a room about a new member, the new member included, before it sends them the room's member list. The roster was started from that echo, so for a moment after joining a room read as holding nobody but us, and `room users` returns on the first roster it sees: it could print only the asking user. That is the flake in room_users_lists_who_is_in_the_room. A join or leave now only updates a roster the server has sent in full, which is also what room_members already promised for a room we have not joined. The e2e test waits for the resident's own member list instead of a fixed second, so it no longer races the resident's join either.
This commit is contained in:
@@ -100,10 +100,12 @@ impl ClientContext {
|
||||
// the whole board again on the next join.
|
||||
self.room_tickers.remove(room);
|
||||
}
|
||||
// Only a roster the server has sent in full is kept current: the
|
||||
// joiner hears of their own arrival before the member list.
|
||||
RoomEvent::UserJoined { room, username } => {
|
||||
let members =
|
||||
self.room_members.entry(room.clone()).or_default();
|
||||
if let Err(at) = members.binary_search(username) {
|
||||
if let Some(members) = self.room_members.get_mut(room)
|
||||
&& let Err(at) = members.binary_search(username)
|
||||
{
|
||||
members.insert(at, username.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user