Merge pull request #745 from krille-chan/krille/hide-add-subspace-button-if-not-admin

chore: Follow up add chat subspace button
This commit is contained in:
Krille-chan 2023-12-23 16:15:57 +01:00 committed by GitHub
commit 709e8c61af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -264,6 +264,11 @@ class _SpaceViewState extends State<SpaceView> {
Widget build(BuildContext context) {
final client = Matrix.of(context).client;
final activeSpaceId = widget.controller.activeSpaceId;
final activeSpace = activeSpaceId == null
? null
: client.getRoomById(
activeSpaceId,
);
final allSpaces = client.rooms.where((room) => room.isSpace);
if (activeSpaceId == null) {
final rootSpaces = allSpaces
@ -446,17 +451,22 @@ class _SpaceViewState extends State<SpaceView> {
),
onTap: () => _onJoinSpaceChild(spaceChild),
),
Material(
child: ListTile(
leading: const CircleAvatar(
child: Icon(Icons.group_add_outlined),
if (activeSpace?.canChangeStateEvent(
EventTypes.spaceChild,
) ==
true)
Material(
child: ListTile(
leading: const CircleAvatar(
child: Icon(Icons.group_add_outlined),
),
title:
Text(L10n.of(context)!.addChatOrSubSpace),
trailing:
const Icon(Icons.chevron_right_outlined),
onTap: _addChatOrSubSpace,
),
title: Text(L10n.of(context)!.addChatOrSubSpace),
trailing:
const Icon(Icons.chevron_right_outlined),
onTap: _addChatOrSubSpace,
),
),
],
);
}