chore: Follow up manage aliases
This commit is contained in:
parent
4dbe85b278
commit
de68f62aef
3 changed files with 40 additions and 8 deletions
|
|
@ -2509,8 +2509,8 @@
|
||||||
"@passwordIsWrong": {},
|
"@passwordIsWrong": {},
|
||||||
"publicLink": "Public link",
|
"publicLink": "Public link",
|
||||||
"@publicLink": {},
|
"@publicLink": {},
|
||||||
"publicLinks": "Public links",
|
"publicChatAddresses": "Public chat addresses",
|
||||||
"createNewLink": "Create new link",
|
"createNewAddress": "Create new address",
|
||||||
"joinSpace": "Join space",
|
"joinSpace": "Join space",
|
||||||
"@joinSpace": {},
|
"@joinSpace": {},
|
||||||
"publicSpaces": "Public spaces",
|
"publicSpaces": "Public spaces",
|
||||||
|
|
|
||||||
|
|
@ -178,6 +178,9 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
||||||
future: () => room.client.setRoomAlias(alias, room.id),
|
future: () => room.client.setRoomAlias(alias, room.id),
|
||||||
);
|
);
|
||||||
if (result.error != null) return;
|
if (result.error != null) return;
|
||||||
|
setState(() {});
|
||||||
|
|
||||||
|
if (!room.canChangeStateEvent(EventTypes.RoomCanonicalAlias)) return;
|
||||||
|
|
||||||
final canonicalAliasConsent = await showOkCancelAlertDialog(
|
final canonicalAliasConsent = await showOkCancelAlertDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -217,10 +220,13 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteAlias(String alias) => showFutureLoadingDialog(
|
void deleteAlias(String alias) async {
|
||||||
context: context,
|
await showFutureLoadingDialog(
|
||||||
future: () => room.client.deleteRoomAlias(alias),
|
context: context,
|
||||||
);
|
future: () => room.client.deleteRoomAlias(alias),
|
||||||
|
);
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
|
||||||
void setChatVisibilityOnDirectory(bool? visibility) async {
|
void setChatVisibilityOnDirectory(bool? visibility) async {
|
||||||
if (visibility == null) return;
|
if (visibility == null) return;
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
||||||
Divider(color: Theme.of(context).dividerColor),
|
Divider(color: Theme.of(context).dividerColor),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
L10n.of(context)!.publicLinks,
|
L10n.of(context)!.publicChatAddresses,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: Theme.of(context).colorScheme.secondary,
|
color: Theme.of(context).colorScheme.secondary,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
|
|
@ -115,7 +115,7 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
||||||
),
|
),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon: const Icon(Icons.add_outlined),
|
icon: const Icon(Icons.add_outlined),
|
||||||
tooltip: L10n.of(context)!.createNewLink,
|
tooltip: L10n.of(context)!.createNewAddress,
|
||||||
onPressed: controller.addAlias,
|
onPressed: controller.addAlias,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -138,6 +138,30 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
||||||
? () => controller.deleteAlias(alias)
|
? () => controller.deleteAlias(alias)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
FutureBuilder(
|
||||||
|
future: room.client.getLocalAliases(room.id),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
final localAddresses = snapshot.data;
|
||||||
|
if (localAddresses == null) {
|
||||||
|
return const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
localAddresses.remove(room.canonicalAlias);
|
||||||
|
localAddresses
|
||||||
|
.removeWhere((alias) => altAliases.contains(alias));
|
||||||
|
return Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: localAddresses
|
||||||
|
.map(
|
||||||
|
(alias) => _AliasListTile(
|
||||||
|
alias: alias,
|
||||||
|
published: false,
|
||||||
|
onDelete: () => controller.deleteAlias(alias),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.toList(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
Divider(color: Theme.of(context).dividerColor),
|
Divider(color: Theme.of(context).dividerColor),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: room.client.getRoomVisibilityOnDirectory(room.id),
|
future: room.client.getRoomVisibilityOnDirectory(room.id),
|
||||||
|
|
@ -190,11 +214,13 @@ class _AliasListTile extends StatelessWidget {
|
||||||
required this.alias,
|
required this.alias,
|
||||||
required this.onDelete,
|
required this.onDelete,
|
||||||
this.isCanonicalAlias = false,
|
this.isCanonicalAlias = false,
|
||||||
|
this.published = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final String alias;
|
final String alias;
|
||||||
final void Function()? onDelete;
|
final void Function()? onDelete;
|
||||||
final bool isCanonicalAlias;
|
final bool isCanonicalAlias;
|
||||||
|
final bool published;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue