From 4afb9a4790cf0e657cb682cf37e02ecf6c84787f Mon Sep 17 00:00:00 2001 From: Krille Date: Sun, 15 Jan 2023 10:05:54 +0100 Subject: [PATCH] chore: Follow up leave abandoned DM room --- lib/pages/chat/chat.dart | 14 ++++++++++++++ lib/pages/chat/chat_view.dart | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index b104218e..f5107580 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -165,6 +165,20 @@ class ChatController extends State { VRouter.of(context).toSegments(['rooms', roomId]); } + void leaveChat() async { + final room = this.room; + if (room == null) { + throw Exception( + 'Leave room button clicked while room is null. This should not be possible from the UI!'); + } + final success = await showFutureLoadingDialog( + context: context, + future: room.leave, + ); + if (success.error != null) return; + VRouter.of(context).to('/rooms'); + } + EmojiPickerType emojiPickerType = EmojiPickerType.keyboard; void requestHistory() async { diff --git a/lib/pages/chat/chat_view.dart b/lib/pages/chat/chat_view.dart index 6c53f79e..dd6faf18 100644 --- a/lib/pages/chat/chat_view.dart +++ b/lib/pages/chat/chat_view.dart @@ -298,6 +298,8 @@ class ChatView extends StatelessWidget { children: [ TextButton.icon( style: TextButton.styleFrom( + padding: + const EdgeInsets.all(16), foregroundColor: Theme.of(context) .colorScheme @@ -306,12 +308,16 @@ class ChatView extends StatelessWidget { icon: const Icon( Icons.archive_outlined, ), - onPressed: () {}, + onPressed: controller.leaveChat, label: Text( L10n.of(context)!.leave, ), ), TextButton.icon( + style: TextButton.styleFrom( + padding: + const EdgeInsets.all(16), + ), icon: const Icon( Icons.chat_outlined, ),