chore: Follow up chat context menu

This commit is contained in:
Krille 2024-07-16 07:31:43 +02:00
commit 467d103c2f
No known key found for this signature in database
GPG key ID: E067ECD60F1A0652

View file

@ -620,6 +620,10 @@ class ChatListController extends State<ChatList>
BuildContext posContext, [ BuildContext posContext, [
Room? space, Room? space,
]) async { ]) async {
if (room.membership == Membership.invite) {
return onChatTap(room);
}
final overlay = final overlay =
Overlay.of(posContext).context.findRenderObject() as RenderBox; Overlay.of(posContext).context.findRenderObject() as RenderBox;
@ -644,7 +648,7 @@ class ChatListController extends State<ChatList>
position: position, position: position,
items: [ items: [
PopupMenuItem( PopupMenuItem(
enabled: false, value: ChatContextAction.open,
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@ -754,12 +758,36 @@ class ChatListController extends State<ChatList>
if (action == null) return; if (action == null) return;
if (!mounted) return; if (!mounted) return;
if (action == ChatContextAction.goToSpace) { switch (action) {
case ChatContextAction.open:
onChatTap(room);
return;
case ChatContextAction.goToSpace:
setActiveSpace(space!.id); setActiveSpace(space!.id);
return; return;
} case ChatContextAction.favorite:
await showFutureLoadingDialog(
if (action == ChatContextAction.leave) { context: context,
future: () => room.setFavourite(!room.isFavourite),
);
return;
case ChatContextAction.markUnread:
await showFutureLoadingDialog(
context: context,
future: () => room.markUnread(!room.markedUnread),
);
return;
case ChatContextAction.mute:
await showFutureLoadingDialog(
context: context,
future: () => room.setPushRuleState(
room.pushRuleState == PushRuleState.notify
? PushRuleState.mentionsOnly
: PushRuleState.notify,
),
);
return;
case ChatContextAction.leave:
final confirmed = await showOkCancelAlertDialog( final confirmed = await showOkCancelAlertDialog(
useRootNavigator: false, useRootNavigator: false,
context: context, context: context,
@ -770,30 +798,11 @@ class ChatListController extends State<ChatList>
isDestructiveAction: true, isDestructiveAction: true,
); );
if (confirmed == OkCancelResult.cancel) return; if (confirmed == OkCancelResult.cancel) return;
if (!mounted) {
await showFutureLoadingDialog(context: context, future: room.leave);
} }
if (!mounted) return;
await showFutureLoadingDialog(
context: context,
future: () async {
switch (action) {
case ChatContextAction.goToSpace:
return; return;
case ChatContextAction.favorite:
return room.setFavourite(!room.isFavourite);
case ChatContextAction.markUnread:
return room.markUnread(!room.markedUnread);
case ChatContextAction.mute:
return room.setPushRuleState(
room.pushRuleState == PushRuleState.notify
? PushRuleState.mentionsOnly
: PushRuleState.notify,
);
case ChatContextAction.leave:
return room.leave();
} }
},
);
} }
void dismissStatusList() async { void dismissStatusList() async {
@ -993,6 +1002,7 @@ enum InviteActions {
enum AddRoomType { chat, subspace } enum AddRoomType { chat, subspace }
enum ChatContextAction { enum ChatContextAction {
open,
goToSpace, goToSpace,
favorite, favorite,
markUnread, markUnread,