Can't add subclass as parent space
This commit is contained in:
parent
c5677e4562
commit
4a0ee3665f
4 changed files with 15 additions and 3 deletions
|
|
@ -815,8 +815,8 @@ class ChatListController extends State<ChatList>
|
|||
&&
|
||||
selectedRoomIds
|
||||
.map((id) => Matrix.of(context).client.getRoomById(id))
|
||||
.where((e) => !(e?.isPangeaClass ?? true))
|
||||
.every((e) => r.canIAddSpaceChild(e)),
|
||||
// .where((e) => !(e?.isPangeaClass ?? true))
|
||||
.every((e) => r.canAddAsParentOf(e)),
|
||||
//Pangea#
|
||||
)
|
||||
.map(
|
||||
|
|
|
|||
|
|
@ -127,4 +127,14 @@ extension ChildrenAndParentsRoomExtension on Room {
|
|||
}
|
||||
return childIds;
|
||||
}
|
||||
|
||||
// Checks if can add chat as child
|
||||
// Or whether potential child space is ancestor of this
|
||||
bool _canAddAsParentOf(Room? child) {
|
||||
if (child == null || !child.isSpace) {
|
||||
return _canIAddSpaceChild(child);
|
||||
}
|
||||
if (id == child.id) return false;
|
||||
return !child._allSpaceChildRoomIds.contains(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,8 @@ extension PangeaRoom on Room {
|
|||
|
||||
List<String> get allSpaceChildRoomIds => _allSpaceChildRoomIds;
|
||||
|
||||
bool canAddAsParentOf(Room? child) => _canAddAsParentOf(child);
|
||||
|
||||
// class_and_exchange_settings
|
||||
|
||||
DateTime? get rulesUpdatedAt => _rulesUpdatedAt;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|||
final Room possibleParent = possibleParents[index];
|
||||
final bool canAdd = !(!possibleParent.isRoomAdmin &&
|
||||
widget.mode == AddToClassMode.exchange) &&
|
||||
possibleParent.canIAddSpaceChild(room);
|
||||
possibleParent.canAddAsParentOf(room);
|
||||
|
||||
return Opacity(
|
||||
opacity: canAdd ? 1 : 0.5,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue