From 388598ef67e833d89fd918e4d0205a93bf801c9d Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 5 Nov 2020 13:43:36 +0100 Subject: [PATCH] fix: Join broken room handling --- lib/src/room.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/room.dart b/lib/src/room.dart index 2788d441..56a41e4f 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -799,7 +799,7 @@ class Room { /// 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 /// automatically be set. - Future join() async { + Future join({bool removeIfNotFound = true}) async { try { await client.joinRoom(id); final invitation = getState(EventTypes.RoomMember, client.userID); @@ -809,7 +809,9 @@ class Room { await addToDirectChat(invitation.sender.id); } } 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); client.onRoomUpdate.add( RoomUpdate(