Lets students add subrooms to spaces
This commit is contained in:
parent
16df497e8a
commit
8cdd9c3b2d
3 changed files with 5 additions and 20 deletions
|
|
@ -819,8 +819,7 @@ class ChatListController extends State<ChatList>
|
|||
label: space.nameIncludingParents(context),
|
||||
// If user is not admin of space, button is grayed out
|
||||
textStyle: TextStyle(
|
||||
color: (firstSelectedRoom == null ||
|
||||
(firstSelectedRoom.isSpace && !space.isRoomAdmin))
|
||||
color: (firstSelectedRoom == null)
|
||||
? Theme.of(context).colorScheme.outline
|
||||
: Theme.of(context).colorScheme.surfaceTint,
|
||||
),
|
||||
|
|
@ -838,10 +837,6 @@ class ChatListController extends State<ChatList>
|
|||
if (firstSelectedRoom == null) {
|
||||
throw L10n.of(context)!.nonexistentSelection;
|
||||
}
|
||||
// If user is not admin of the would-be parent space, does not allow
|
||||
if (firstSelectedRoom.isSpace && !space.isRoomAdmin) {
|
||||
throw L10n.of(context)!.cantAddSpaceChild;
|
||||
}
|
||||
|
||||
if (space.canSendDefaultStates) {
|
||||
for (final roomId in selectedRoomIds) {
|
||||
|
|
|
|||
|
|
@ -291,6 +291,8 @@ extension PangeaRoom on Room {
|
|||
|
||||
bool get canDelete => _canDelete;
|
||||
|
||||
/// Determines whether user has permission to add child room to this
|
||||
/// Can add child if, and only if, is admin of child
|
||||
bool canIAddSpaceChild(Room? room, {bool spaceMode = false}) {
|
||||
return _canIAddSpaceChild(room, spaceMode: spaceMode);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,20 +88,8 @@ extension UserPermissionsRoomExtension on Room {
|
|||
return false;
|
||||
}
|
||||
|
||||
final isSpaceAdmin = isRoomAdmin;
|
||||
final isChildRoomAdmin = room?.isRoomAdmin ?? true;
|
||||
|
||||
// if user is not admin of child room, return false
|
||||
if (!isChildRoomAdmin) return false;
|
||||
|
||||
// if the child room is a space, or will be a space,
|
||||
// then the user must be an admin of the parent space
|
||||
if (room?.isSpace ?? spaceMode) return isSpaceAdmin;
|
||||
|
||||
// otherwise, the user can add the child room to the parent
|
||||
// if they're the admin of the parent or if the parent creation
|
||||
// of group chats
|
||||
return isSpaceAdmin || (pangeaRoomRules?.isCreateRooms ?? false);
|
||||
// Can add child if, and only if, admin of child
|
||||
return room?.isRoomAdmin ?? true;
|
||||
}
|
||||
|
||||
bool get _canIAddSpaceParents =>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue