diff --git a/lib/src/room.dart b/lib/src/room.dart index f07a5fd4..053aa15f 100644 --- a/lib/src/room.dart +++ b/lib/src/room.dart @@ -348,11 +348,13 @@ class Room { } } - return client.directChats.entries + final mxId = client.directChats.entries .firstWhereOrNull((MapEntry e) { final roomIds = e.value; return roomIds is List && roomIds.contains(id); })?.key; + if (mxId?.isValidMatrixId == true) return mxId; + return null; } /// Wheither this is a direct chat or not @@ -1591,7 +1593,7 @@ class Room { if (user != null) { return user.asUser; } else { - requestUser(mxID, ignoreErrors: true); + if (mxID.isValidMatrixId) requestUser(mxID, ignoreErrors: true); return User(mxID, room: this); } } @@ -1606,6 +1608,8 @@ class Room { bool ignoreErrors = false, bool requestProfile = true, }) async { + assert(mxID.isValidMatrixId); + // Checks if the user is really missing final stateUser = getState(EventTypes.RoomMember, mxID); if (stateUser != null) {