Use onError for other functions
This commit is contained in:
parent
23c56caa2d
commit
3d8c80976a
|
@ -183,7 +183,7 @@ class Client {
|
|||
Future<void> logout() async {
|
||||
final dynamic resp = await connection.jsonRequest(
|
||||
type: "POST", action: "/client/r0/logout/all");
|
||||
if (resp == null) return;
|
||||
if (resp is ErrorResponse) connection.onError.add(resp);
|
||||
|
||||
await connection.clear();
|
||||
}
|
||||
|
@ -194,11 +194,16 @@ class Client {
|
|||
List<String> inviteIDs = [];
|
||||
for (int i = 0; i < users.length; i++) inviteIDs.add(users[i].id);
|
||||
|
||||
Map<String, dynamic> resp = await connection.jsonRequest(
|
||||
final dynamic resp = await connection.jsonRequest(
|
||||
type: "POST",
|
||||
action: "/client/r0/createRoom",
|
||||
data: {"invite": inviteIDs, "preset": "private_chat"});
|
||||
|
||||
if (resp is ErrorResponse) {
|
||||
connection.onError.add(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
return resp["room_id"];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue