Return error on startDirectChat error

This commit is contained in:
Christian Pauly 2019-06-12 13:54:04 +02:00
parent 502623ad31
commit fea52b777f
1 changed files with 4 additions and 3 deletions

View File

@ -125,8 +125,9 @@ class User {
return res; return res;
} }
/// Returns an existing direct chat with this user or creates a new one. /// Returns an existing direct chat ID with this user or creates a new one.
Future<String> startDirectChat() async { /// May return ErrorResponse on error.
Future<dynamic> startDirectChat() async {
// Try to find an existing direct chat // Try to find an existing direct chat
String roomID = await room.client?.store.getDirectChatRoomID(id); String roomID = await room.client?.store.getDirectChatRoomID(id);
if (roomID != null) return roomID; if (roomID != null) return roomID;
@ -139,7 +140,7 @@ class User {
"preset": "trusted_private_chat" "preset": "trusted_private_chat"
}); });
if (resp is ErrorResponse || resp["room_id"] == null) return null; if (resp is ErrorResponse || resp["room_id"] == null) return resp;
final String newRoomID = resp["room_id"]; final String newRoomID = resp["room_id"];