mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
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:
parent
b7fd22c7f9
commit
0bf021ea87
@ -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) {
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user