fix: Join broken room handling

This commit is contained in:
Christian Pauly 2020-11-05 13:43:36 +01:00
parent 15d817023d
commit 388598ef67
1 changed files with 4 additions and 2 deletions

View File

@ -799,7 +799,7 @@ class Room {
/// Call the Matrix API to join this room if the user is not already a member. /// Call the Matrix API to join this room if the user is not already a member.
/// If this room is intended to be a direct chat, the direct chat flag will /// If this room is intended to be a direct chat, the direct chat flag will
/// automatically be set. /// automatically be set.
Future<void> join() async { Future<void> join({bool removeIfNotFound = true}) async {
try { try {
await client.joinRoom(id); await client.joinRoom(id);
final invitation = getState(EventTypes.RoomMember, client.userID); final invitation = getState(EventTypes.RoomMember, client.userID);
@ -809,7 +809,9 @@ class Room {
await addToDirectChat(invitation.sender.id); await addToDirectChat(invitation.sender.id);
} }
} on MatrixException catch (exception) { } on MatrixException catch (exception) {
if (exception.errorMessage == 'No known servers') { if (removeIfNotFound &&
[MatrixError.M_NOT_FOUND, MatrixError.M_UNKNOWN]
.contains(exception.error)) {
await client.database?.forgetRoom(client.id, id); await client.database?.forgetRoom(client.id, id);
client.onRoomUpdate.add( client.onRoomUpdate.add(
RoomUpdate( RoomUpdate(