diff --git a/lib/src/Room.dart b/lib/src/Room.dart index 855672d..b755aa6 100644 --- a/lib/src/Room.dart +++ b/lib/src/Room.dart @@ -44,7 +44,7 @@ class Room { String topic; /// The avatar of the room if set by a participant. - MxContent avatar; + MxContent avatar = MxContent(""); /// The count of unread notifications. int notificationCount; diff --git a/lib/src/User.dart b/lib/src/User.dart index 4b777ce..bb3e782 100644 --- a/lib/src/User.dart +++ b/lib/src/User.dart @@ -132,20 +132,19 @@ class User { if (roomID != null) return roomID; // Start a new direct chat - Map resp = await room.client.connection + final dynamic resp = await room.client.connection .jsonRequest(type: "POST", action: "/client/r0/createRoom", data: { "invite": [id], "is_direct": true, "preset": "trusted_private_chat" }); - if (resp is ErrorResponse) return null; + if (resp is ErrorResponse || resp["room_id"] == null) return null; - // TODO: Update m.direct data - /*room.client.connection.jsonRequest(type: "PUT", action: "/client/r0/user/${room.client.userID}/account_data/m.direct", data: { + final String newRoomID = resp["room_id"]; - });*/ + await Room(id: newRoomID).addToDirectChat(id); - return resp["room_id"]; + return newRoomID; } }