feat: add handling for sub-room creation by setting parent-child relationships and copying join rules
This commit is contained in:
@@ -64,6 +64,26 @@ function CreateRoomModal({ state }: CreateRoomModalProps) {
|
|||||||
parentSubRoomId
|
parentSubRoomId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Set m.space.child on the parent room pointing to this sub-room
|
||||||
|
await mx.sendStateEvent(
|
||||||
|
parentSubRoomId,
|
||||||
|
StateEvent.SpaceChild,
|
||||||
|
{ via: viaServers },
|
||||||
|
newRoomId
|
||||||
|
);
|
||||||
|
|
||||||
|
// Copy parent's join_rules to the sub-room
|
||||||
|
const parentJoinRulesEvent = parentRoom.currentState.getStateEvents(StateEvent.RoomJoinRules, '');
|
||||||
|
if (parentJoinRulesEvent) {
|
||||||
|
const joinRulesContent = parentJoinRulesEvent.getContent();
|
||||||
|
await mx.sendStateEvent(
|
||||||
|
newRoomId,
|
||||||
|
StateEvent.RoomJoinRules,
|
||||||
|
joinRulesContent,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Add new room to parent's sub-rooms list
|
// Add new room to parent's sub-rooms list
|
||||||
const stateEvent = parentRoom.currentState.getStateEvents(StateEvent.PaarrotSubRooms, '');
|
const stateEvent = parentRoom.currentState.getStateEvents(StateEvent.PaarrotSubRooms, '');
|
||||||
const currentContent = stateEvent?.getContent() as PaarrotSubRoomsContent | undefined;
|
const currentContent = stateEvent?.getContent() as PaarrotSubRoomsContent | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user