The room is now joined after having actualised the rooms list, to avoid the synchronisations waits that can sometimes disable to enter the room (message "You're not into this room" or simply "You're not in this room yet. *Join the room*")

This commit is contained in:
Kaki In 2022-07-25 13:37:03 +02:00
parent b7fd22c7f9
commit 0bf021ea87
2 changed files with 18 additions and 1 deletions

View File

@ -210,8 +210,8 @@ export class RoomViewModel extends ViewModel {
if (args.length == 1) {
let roomName = args[0];
try {
await this._options.client.session.joinRoom(roomName);
const internalId = await this._options.client.session.joinRoom(roomName);
await this._options.client.session.waitForRoomFromSync(internalId);
this.navigation.push("room", internalId);
} catch (exc) {
if ((exc.statusCode ?? exc.status) === 400) {

View File

@ -948,6 +948,23 @@ export class Session {
return body.room_id;
});
}
waitForRoomFromSync(roomId) {
let resolve;
const promise = new Promise(r => { resolve = r; })
const subscription = {
onAdd: (_, value) => {
if (value.id === roomId) {
this._session.rooms.unsubscribe(subscription);
resolve();
}
},
onUpdate: () => undefined,
onRemove: () => undefined,
};
this._session.rooms.subscribe(subscription);
return promise;
}
}
export function tests() {