fix: mark DMs as DMs properly when joining
If we join first, it is possible that our member event is not the invite event anymore. As such we should fetch that state first, before joining. But also there is little reason not to mark the room as a DM immediately. That prevents the room from temporarily becoming a group room, that might be visible in the UI temporarily. fixes https://gitlab.com/famedly/company/product-management/-/issues/1006
This commit is contained in:
parent
6e67835872
commit
47c54cb397
|
|
@ -1133,13 +1133,15 @@ class Room {
|
||||||
/// automatically be set.
|
/// automatically be set.
|
||||||
Future<void> join({bool leaveIfNotFound = true}) async {
|
Future<void> join({bool leaveIfNotFound = true}) async {
|
||||||
try {
|
try {
|
||||||
await client.joinRoomById(id);
|
// If this is a DM, mark it as a DM first, because otherwise the current member
|
||||||
final invitation = getState(EventTypes.RoomMember, client.userID!);
|
// event might be the join event already and there is also a race condition there for SDK users.
|
||||||
if (invitation != null &&
|
final dmId = directChatMatrixID;
|
||||||
invitation.content['is_direct'] is bool &&
|
if (dmId != null) {
|
||||||
invitation.content['is_direct']) {
|
await addToDirectChat(dmId);
|
||||||
await addToDirectChat(invitation.senderId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// now join
|
||||||
|
await client.joinRoomById(id);
|
||||||
} on MatrixException catch (exception) {
|
} on MatrixException catch (exception) {
|
||||||
if (leaveIfNotFound &&
|
if (leaveIfNotFound &&
|
||||||
[MatrixError.M_NOT_FOUND, MatrixError.M_UNKNOWN]
|
[MatrixError.M_NOT_FOUND, MatrixError.M_UNKNOWN]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue