mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 03:05:14 +00:00
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": {},
|
||||
"publicLink": "Public link",
|
||||
"@publicLink": {},
|
||||
"publicLinks": "Public links",
|
||||
"createNewLink": "Create new link",
|
||||
"publicChatAddresses": "Public chat addresses",
|
||||
"createNewAddress": "Create new address",
|
||||
"joinSpace": "Join space",
|
||||
"@joinSpace": {},
|
||||
"publicSpaces": "Public spaces",
|
||||
|
|
|
@ -178,6 +178,9 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
future: () => room.client.setRoomAlias(alias, room.id),
|
||||
);
|
||||
if (result.error != null) return;
|
||||
setState(() {});
|
||||
|
||||
if (!room.canChangeStateEvent(EventTypes.RoomCanonicalAlias)) return;
|
||||
|
||||
final canonicalAliasConsent = await showOkCancelAlertDialog(
|
||||
context: context,
|
||||
|
@ -217,10 +220,13 @@ class ChatAccessSettingsController extends State<ChatAccessSettings> {
|
|||
);
|
||||
}
|
||||
|
||||
void deleteAlias(String alias) => showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client.deleteRoomAlias(alias),
|
||||
);
|
||||
void deleteAlias(String alias) async {
|
||||
await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => room.client.deleteRoomAlias(alias),
|
||||
);
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
void setChatVisibilityOnDirectory(bool? visibility) async {
|
||||
if (visibility == null) return;
|
||||
|
|
|
@ -107,7 +107,7 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
Divider(color: Theme.of(context).dividerColor),
|
||||
ListTile(
|
||||
title: Text(
|
||||
L10n.of(context)!.publicLinks,
|
||||
L10n.of(context)!.publicChatAddresses,
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).colorScheme.secondary,
|
||||
fontWeight: FontWeight.bold,
|
||||
|
@ -115,7 +115,7 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
),
|
||||
trailing: IconButton(
|
||||
icon: const Icon(Icons.add_outlined),
|
||||
tooltip: L10n.of(context)!.createNewLink,
|
||||
tooltip: L10n.of(context)!.createNewAddress,
|
||||
onPressed: controller.addAlias,
|
||||
),
|
||||
),
|
||||
|
@ -138,6 +138,30 @@ class ChatAccessSettingsPageView extends StatelessWidget {
|
|||
? () => controller.deleteAlias(alias)
|
||||
: 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),
|
||||
FutureBuilder(
|
||||
future: room.client.getRoomVisibilityOnDirectory(room.id),
|
||||
|
@ -190,11 +214,13 @@ class _AliasListTile extends StatelessWidget {
|
|||
required this.alias,
|
||||
required this.onDelete,
|
||||
this.isCanonicalAlias = false,
|
||||
this.published = true,
|
||||
});
|
||||
|
||||
final String alias;
|
||||
final void Function()? onDelete;
|
||||
final bool isCanonicalAlias;
|
||||
final bool published;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
Loading…
Reference in a new issue