fix: Set space

This commit is contained in:
Krille Fear 2021-11-15 08:20:29 +01:00
parent 97e644b64a
commit 7c3fffc8a6
2 changed files with 22 additions and 6 deletions

View File

@ -2618,5 +2618,8 @@
"time": "Time",
"messageType": "Message Type",
"sender": "Sender",
"openGallery": "Open gallery"
"openGallery": "Open gallery",
"removeFromSpace": "Remove from space",
"removeFromSpaceDescription": "This removes this chat from the current space. It will then still be visible under \"All chats\".",
"addToSpaceDescription": "Select a space to add this chat to it."
}

View File

@ -356,6 +356,17 @@ class ChatListController extends State<ChatList> {
Future<void> addOrRemoveToSpace() async {
if (activeSpaceId != null) {
final consent = await showOkCancelAlertDialog(
context: context,
title: L10n.of(context).removeFromSpace,
message: L10n.of(context).removeFromSpaceDescription,
okLabel: L10n.of(context).remove,
cancelLabel: L10n.of(context).cancel,
isDestructiveAction: true,
fullyCapitalizedForMaterial: false,
);
if (consent != OkCancelResult.ok) return;
final space = Matrix.of(context).client.getRoomById(activeSpaceId);
final result = await showFutureLoadingDialog(
context: context,
@ -376,6 +387,8 @@ class ChatListController extends State<ChatList> {
final selectedSpace = await showConfirmationDialog<String>(
context: context,
title: L10n.of(context).addToSpace,
message: L10n.of(context).addToSpaceDescription,
fullyCapitalizedForMaterial: false,
actions: Matrix.of(context)
.client
.rooms
@ -391,11 +404,11 @@ class ChatListController extends State<ChatList> {
final result = await showFutureLoadingDialog(
context: context,
future: () async {
for (final roomId in selectedRoomIds) {
await Matrix.of(context)
.client
.getRoomById(selectedSpace)
.setSpaceChild(roomId);
final space = Matrix.of(context).client.getRoomById(selectedSpace);
if (space.canSendDefaultStates) {
for (final roomId in selectedRoomIds) {
await space.setSpaceChild(roomId);
}
}
},
);