File tree Expand file tree Collapse file tree 1 file changed +15
-4
lines changed
Expand file tree Collapse file tree 1 file changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -2690,10 +2690,21 @@ class Room {
26902690 );
26912691 }
26922692
2693- /// Remove a child from this space by setting the `via` to an empty list.
2694- Future <void > removeSpaceChild (String roomId) => ! isSpace
2695- ? throw Exception ('Room is not a space!' )
2696- : setSpaceChild (roomId, via: const []);
2693+ /// Remove a child from this space by removing the space child and optionally
2694+ /// space parent state events.
2695+ Future <void > removeSpaceChild (String roomId) async {
2696+ if (! isSpace) throw Exception ('Room is not a space!' );
2697+
2698+ await client.setRoomStateWithKey (id, EventTypes .SpaceChild , roomId, {});
2699+
2700+ // Optionally remove the space parent state event in the former space child.
2701+ if (client
2702+ .getRoomById (roomId)
2703+ ? .canChangeStateEvent (EventTypes .SpaceParent ) ==
2704+ true ) {
2705+ await client.setRoomStateWithKey (roomId, EventTypes .SpaceParent , id, {});
2706+ }
2707+ }
26972708
26982709 @override
26992710 bool operator == (Object other) => (other is Room && other.id == id);
You can’t perform that action at this time.
0 commit comments