fix: Correctly remove space child
This commit is contained in:
parent
2a81bcf885
commit
86d1eb85f9
|
|
@ -2690,10 +2690,21 @@ class Room {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a child from this space by setting the `via` to an empty list.
|
/// Remove a child from this space by removing the space child and optionally
|
||||||
Future<void> removeSpaceChild(String roomId) => !isSpace
|
/// space parent state events.
|
||||||
? throw Exception('Room is not a space!')
|
Future<void> removeSpaceChild(String roomId) async {
|
||||||
: setSpaceChild(roomId, via: const []);
|
if (!isSpace) throw Exception('Room is not a space!');
|
||||||
|
|
||||||
|
await client.setRoomStateWithKey(id, EventTypes.SpaceChild, roomId, {});
|
||||||
|
|
||||||
|
// Optionally remove the space parent state event in the former space child.
|
||||||
|
if (client
|
||||||
|
.getRoomById(roomId)
|
||||||
|
?.canChangeStateEvent(EventTypes.SpaceParent) ==
|
||||||
|
true) {
|
||||||
|
await client.setRoomStateWithKey(roomId, EventTypes.SpaceParent, id, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) => (other is Room && other.id == id);
|
bool operator ==(Object other) => (other is Room && other.id == id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue