fix parsing links as mentions

This commit is contained in:
Henry Hiles 2026-04-04 21:33:31 -04:00
commit 4aa962193d
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
3 changed files with 6 additions and 6 deletions

View file

@ -12,7 +12,7 @@ extension JoinRoomWithSnackbars on ClientController {
String roomAlias,
WidgetRef ref,
) async {
final roomIdOrAlias = roomAlias.mention;
final roomIdOrAlias = roomAlias.mention ?? roomAlias;
// TODO: Parse vias properly
final scaffoldMessenger = ScaffoldMessenger.of(context);

View file

@ -9,7 +9,7 @@ extension LinkToMention on String {
///
/// Returns the decoded identifier (e.g. "#room:matrix.org")
/// or null if this is not a Matrix link.
String get mention {
String? get mention {
final trimmed = trim();
final matrixTo = RegExp(
@ -39,6 +39,6 @@ extension LinkToMention on String {
} catch (_) {}
}
return this;
return null;
}
}

View file

@ -10,9 +10,9 @@ class MentionChip extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final membership = content.mention.startsWith("@") == true
final membership = content.mention!.startsWith("@") == true
? ref
.watch(UserController.provider(content.mention))
.watch(UserController.provider(content.mention!))
.whenOrNull(data: (data) => data)
: null;
@ -30,7 +30,7 @@ class MentionChip extends ConsumerWidget {
child: Chip(
label: Text(
(membership == null ? null : "@${membership.displayName}") ??
content.mention,
content.mention!,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.onPrimary,