|
|
|
|
@ -797,6 +797,10 @@ class ChatListController extends State<ChatList>
|
|
|
|
|
// Pangea#
|
|
|
|
|
|
|
|
|
|
Future<void> addToSpace() async {
|
|
|
|
|
// #Pangea
|
|
|
|
|
final firstSelectedRoom =
|
|
|
|
|
Matrix.of(context).client.getRoomById(selectedRoomIds.toList().first);
|
|
|
|
|
// Pangea#
|
|
|
|
|
final selectedSpace = await showConfirmationDialog<String>(
|
|
|
|
|
context: context,
|
|
|
|
|
title: L10n.of(context)!.addToSpace,
|
|
|
|
|
@ -815,8 +819,9 @@ class ChatListController extends State<ChatList>
|
|
|
|
|
&&
|
|
|
|
|
selectedRoomIds
|
|
|
|
|
.map((id) => Matrix.of(context).client.getRoomById(id))
|
|
|
|
|
.where((e) => !(e?.isPangeaClass ?? true))
|
|
|
|
|
.every((e) => r.canIAddSpaceChild(e)),
|
|
|
|
|
// Only show non-recursion-causing spaces
|
|
|
|
|
// Performs a few other checks as well
|
|
|
|
|
.every((e) => r.canAddAsParentOf(e)),
|
|
|
|
|
//Pangea#
|
|
|
|
|
)
|
|
|
|
|
.map(
|
|
|
|
|
@ -826,6 +831,13 @@ class ChatListController extends State<ChatList>
|
|
|
|
|
// label: space
|
|
|
|
|
// .getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
|
|
|
|
label: space.nameIncludingParents(context),
|
|
|
|
|
// If user is not admin of space, button is grayed out
|
|
|
|
|
textStyle: TextStyle(
|
|
|
|
|
color: (firstSelectedRoom == null ||
|
|
|
|
|
(firstSelectedRoom.isSpace && !space.isRoomAdmin))
|
|
|
|
|
? Theme.of(context).colorScheme.outline
|
|
|
|
|
: Theme.of(context).colorScheme.surfaceTint,
|
|
|
|
|
),
|
|
|
|
|
// Pangea#
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
@ -837,12 +849,20 @@ class ChatListController extends State<ChatList>
|
|
|
|
|
future: () async {
|
|
|
|
|
final space = Matrix.of(context).client.getRoomById(selectedSpace)!;
|
|
|
|
|
// #Pangea
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
await pangeaAddToSpace(
|
|
|
|
|
space,
|
|
|
|
|
selectedRoomIds.toList(),
|
|
|
|
|
context,
|
|
|
|
|
pangeaController,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// if (space.canSendDefaultStates) {
|
|
|
|
|
// for (final roomId in selectedRoomIds) {
|
|
|
|
|
// await space.setSpaceChild(roomId);
|
|
|
|
|
@ -855,7 +875,10 @@ class ChatListController extends State<ChatList>
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
SnackBar(
|
|
|
|
|
content: Text(L10n.of(context)!.chatHasBeenAddedToThisSpace),
|
|
|
|
|
// #Pangea
|
|
|
|
|
// content: Text(L10n.of(context)!.chatHasBeenAddedToThisSpace),
|
|
|
|
|
content: Text(L10n.of(context)!.roomAddedToSpace),
|
|
|
|
|
// Pangea#
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|