chore: Bring back add to space feature
This commit is contained in:
parent
641343d5fe
commit
84075133fa
1 changed files with 41 additions and 0 deletions
|
|
@ -563,6 +563,15 @@ class ChatListController extends State<ChatList>
|
||||||
final displayname =
|
final displayname =
|
||||||
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!));
|
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!));
|
||||||
|
|
||||||
|
final spacesWithPowerLevels = room.client.rooms
|
||||||
|
.where(
|
||||||
|
(space) =>
|
||||||
|
space.isSpace &&
|
||||||
|
space.canChangeStateEvent(EventTypes.SpaceChild) &&
|
||||||
|
!space.spaceChildren.any((c) => c.roomId == room.id),
|
||||||
|
)
|
||||||
|
.toList();
|
||||||
|
|
||||||
final action = await showMenu<ChatContextAction>(
|
final action = await showMenu<ChatContextAction>(
|
||||||
context: posContext,
|
context: posContext,
|
||||||
position: position,
|
position: position,
|
||||||
|
|
@ -661,6 +670,18 @@ class ChatListController extends State<ChatList>
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (spacesWithPowerLevels.isNotEmpty)
|
||||||
|
PopupMenuItem(
|
||||||
|
value: ChatContextAction.addToSpace,
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.group_work_outlined),
|
||||||
|
const SizedBox(width: 12),
|
||||||
|
Text(L10n.of(context)!.addToSpace),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: ChatContextAction.leave,
|
value: ChatContextAction.leave,
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|
@ -723,6 +744,25 @@ class ChatListController extends State<ChatList>
|
||||||
await showFutureLoadingDialog(context: context, future: room.leave);
|
await showFutureLoadingDialog(context: context, future: room.leave);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
case ChatContextAction.addToSpace:
|
||||||
|
final space = await showConfirmationDialog(
|
||||||
|
context: context,
|
||||||
|
title: L10n.of(context)!.space,
|
||||||
|
actions: spacesWithPowerLevels
|
||||||
|
.map(
|
||||||
|
(space) => AlertDialogAction(
|
||||||
|
key: space,
|
||||||
|
label: space
|
||||||
|
.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
if (space == null) return;
|
||||||
|
await showFutureLoadingDialog(
|
||||||
|
context: context,
|
||||||
|
future: () => space.setSpaceChild(room.id),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -927,4 +967,5 @@ enum ChatContextAction {
|
||||||
markUnread,
|
markUnread,
|
||||||
mute,
|
mute,
|
||||||
leave,
|
leave,
|
||||||
|
addToSpace,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue