chore: Follow up chat context menu
This commit is contained in:
parent
b05eb891a6
commit
467d103c2f
1 changed files with 50 additions and 40 deletions
|
|
@ -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,46 +758,51 @@ 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) {
|
||||||
setActiveSpace(space!.id);
|
case ChatContextAction.open:
|
||||||
return;
|
onChatTap(room);
|
||||||
}
|
return;
|
||||||
|
case ChatContextAction.goToSpace:
|
||||||
if (action == ChatContextAction.leave) {
|
setActiveSpace(space!.id);
|
||||||
final confirmed = await showOkCancelAlertDialog(
|
return;
|
||||||
useRootNavigator: false,
|
case ChatContextAction.favorite:
|
||||||
context: context,
|
await showFutureLoadingDialog(
|
||||||
title: L10n.of(context)!.areYouSure,
|
context: context,
|
||||||
okLabel: L10n.of(context)!.leave,
|
future: () => room.setFavourite(!room.isFavourite),
|
||||||
cancelLabel: L10n.of(context)!.no,
|
);
|
||||||
message: L10n.of(context)!.archiveRoomDescription,
|
return;
|
||||||
isDestructiveAction: true,
|
case ChatContextAction.markUnread:
|
||||||
);
|
await showFutureLoadingDialog(
|
||||||
if (confirmed == OkCancelResult.cancel) return;
|
context: context,
|
||||||
}
|
future: () => room.markUnread(!room.markedUnread),
|
||||||
if (!mounted) return;
|
);
|
||||||
|
return;
|
||||||
await showFutureLoadingDialog(
|
case ChatContextAction.mute:
|
||||||
context: context,
|
await showFutureLoadingDialog(
|
||||||
future: () async {
|
context: context,
|
||||||
switch (action) {
|
future: () => room.setPushRuleState(
|
||||||
case ChatContextAction.goToSpace:
|
room.pushRuleState == PushRuleState.notify
|
||||||
return;
|
? PushRuleState.mentionsOnly
|
||||||
case ChatContextAction.favorite:
|
: PushRuleState.notify,
|
||||||
return room.setFavourite(!room.isFavourite);
|
),
|
||||||
case ChatContextAction.markUnread:
|
);
|
||||||
return room.markUnread(!room.markedUnread);
|
return;
|
||||||
case ChatContextAction.mute:
|
case ChatContextAction.leave:
|
||||||
return room.setPushRuleState(
|
final confirmed = await showOkCancelAlertDialog(
|
||||||
room.pushRuleState == PushRuleState.notify
|
useRootNavigator: false,
|
||||||
? PushRuleState.mentionsOnly
|
context: context,
|
||||||
: PushRuleState.notify,
|
title: L10n.of(context)!.areYouSure,
|
||||||
);
|
okLabel: L10n.of(context)!.leave,
|
||||||
case ChatContextAction.leave:
|
cancelLabel: L10n.of(context)!.no,
|
||||||
return room.leave();
|
message: L10n.of(context)!.archiveRoomDescription,
|
||||||
|
isDestructiveAction: true,
|
||||||
|
);
|
||||||
|
if (confirmed == OkCancelResult.cancel) return;
|
||||||
|
if (!mounted) {
|
||||||
|
await showFutureLoadingDialog(context: context, future: room.leave);
|
||||||
}
|
}
|
||||||
},
|
return;
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue