fix: make some Room getters null safe

- gixes huge error cause in integration tests of related apps

Signed-off-by: TheOneWithTheBraid <the-one@with-the-braid.cf>
This commit is contained in:
TheOneWithTheBraid 2022-12-14 21:15:18 +01:00
parent a1a22d411f
commit 35a108b704
1 changed files with 6 additions and 2 deletions

View File

@ -272,7 +272,9 @@ class Room {
}
}
if (membership == Membership.invite) {
return getState(EventTypes.RoomMember, client.userID!)
final userID = client.userID;
if (userID == null) return null;
return getState(EventTypes.RoomMember, userID)
?.senderFromMemoryOrFallback
.avatarUrl;
}
@ -301,7 +303,9 @@ class Room {
/// Returns null otherwise.
String? get directChatMatrixID {
if (membership == Membership.invite) {
final invitation = getState(EventTypes.RoomMember, client.userID!);
final userID = client.userID;
if (userID == null) return null;
final invitation = getState(EventTypes.RoomMember, userID);
if (invitation != null && invitation.content['is_direct'] == true) {
return invitation.senderId;
}