fix parsing links as mentions
This commit is contained in:
parent
24f5f7d0b6
commit
4aa962193d
3 changed files with 6 additions and 6 deletions
|
|
@ -12,7 +12,7 @@ extension JoinRoomWithSnackbars on ClientController {
|
||||||
String roomAlias,
|
String roomAlias,
|
||||||
WidgetRef ref,
|
WidgetRef ref,
|
||||||
) async {
|
) async {
|
||||||
final roomIdOrAlias = roomAlias.mention;
|
final roomIdOrAlias = roomAlias.mention ?? roomAlias;
|
||||||
// TODO: Parse vias properly
|
// TODO: Parse vias properly
|
||||||
|
|
||||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ extension LinkToMention on String {
|
||||||
///
|
///
|
||||||
/// Returns the decoded identifier (e.g. "#room:matrix.org")
|
/// Returns the decoded identifier (e.g. "#room:matrix.org")
|
||||||
/// or null if this is not a Matrix link.
|
/// or null if this is not a Matrix link.
|
||||||
String get mention {
|
String? get mention {
|
||||||
final trimmed = trim();
|
final trimmed = trim();
|
||||||
|
|
||||||
final matrixTo = RegExp(
|
final matrixTo = RegExp(
|
||||||
|
|
@ -39,6 +39,6 @@ extension LinkToMention on String {
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ class MentionChip extends ConsumerWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final membership = content.mention.startsWith("@") == true
|
final membership = content.mention!.startsWith("@") == true
|
||||||
? ref
|
? ref
|
||||||
.watch(UserController.provider(content.mention))
|
.watch(UserController.provider(content.mention!))
|
||||||
.whenOrNull(data: (data) => data)
|
.whenOrNull(data: (data) => data)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|
@ -30,7 +30,7 @@ class MentionChip extends ConsumerWidget {
|
||||||
child: Chip(
|
child: Chip(
|
||||||
label: Text(
|
label: Text(
|
||||||
(membership == null ? null : "@${membership.displayName}") ??
|
(membership == null ? null : "@${membership.displayName}") ??
|
||||||
content.mention,
|
content.mention!,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Theme.of(context).colorScheme.onPrimary,
|
color: Theme.of(context).colorScheme.onPrimary,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue