From 7c3fffc8a65a31ccdd28198333437b27d2686140 Mon Sep 17 00:00:00 2001 From: Krille Fear Date: Mon, 15 Nov 2021 08:20:29 +0100 Subject: [PATCH] fix: Set space --- assets/l10n/intl_en.arb | 5 ++++- lib/pages/chat_list/chat_list.dart | 23 ++++++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 60024907..95e6e0fb 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -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." } diff --git a/lib/pages/chat_list/chat_list.dart b/lib/pages/chat_list/chat_list.dart index 3688093b..5d3677a9 100644 --- a/lib/pages/chat_list/chat_list.dart +++ b/lib/pages/chat_list/chat_list.dart @@ -356,6 +356,17 @@ class ChatListController extends State { Future 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 { final selectedSpace = await showConfirmationDialog( 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 { 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); + } } }, );