Fix joining room using via servers regression

This commit is contained in:
Michael Telatynski 2021-04-28 09:04:02 +01:00
parent 31b9a4c312
commit 5966fade0b

View file

@ -60,6 +60,8 @@ const INITIAL_STATE = {
replyingToEvent: null, replyingToEvent: null,
shouldPeek: false, shouldPeek: false,
viaServers: [],
}; };
/** /**
@ -113,6 +115,7 @@ class RoomViewStore extends Store<ActionPayload> {
this.setState({ this.setState({
roomId: null, roomId: null,
roomAlias: null, roomAlias: null,
viaServers: [],
}); });
break; break;
case 'view_room_error': case 'view_room_error':
@ -191,6 +194,7 @@ class RoomViewStore extends Store<ActionPayload> {
replyingToEvent: null, replyingToEvent: null,
// pull the user out of Room Settings // pull the user out of Room Settings
isEditingSettings: false, isEditingSettings: false,
viaServers: payload.via_servers,
}; };
// Allow being given an event to be replied to when switching rooms but sanity check its for this room // Allow being given an event to be replied to when switching rooms but sanity check its for this room
@ -226,6 +230,7 @@ class RoomViewStore extends Store<ActionPayload> {
roomAlias: payload.room_alias, roomAlias: payload.room_alias,
roomLoading: true, roomLoading: true,
roomLoadError: null, roomLoadError: null,
viaServers: payload.via_servers,
}); });
try { try {
const result = await MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias); const result = await MatrixClientPeg.get().getRoomIdForAlias(payload.room_alias);
@ -261,6 +266,7 @@ class RoomViewStore extends Store<ActionPayload> {
roomAlias: payload.room_alias, roomAlias: payload.room_alias,
roomLoading: false, roomLoading: false,
roomLoadError: payload.err, roomLoadError: payload.err,
viaServers: [],
}); });
} }
@ -273,8 +279,9 @@ class RoomViewStore extends Store<ActionPayload> {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
const address = this.state.roomAlias || this.state.roomId; const address = this.state.roomAlias || this.state.roomId;
try { try {
const viaServers = this.state.viaServers || [];
await retry<void, MatrixError>(() => cli.joinRoom(address, { await retry<void, MatrixError>(() => cli.joinRoom(address, {
viaServers: payload.via_servers, viaServers,
...payload.opts, ...payload.opts,
}), NUM_JOIN_RETRY, (err) => { }), NUM_JOIN_RETRY, (err) => {
// if we received a Gateway timeout then retry // if we received a Gateway timeout then retry