Pass href to mention chip, fixing some mentions

This commit is contained in:
Henry Hiles 2026-04-04 18:36:20 -04:00
commit fd4b16c700
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 9 additions and 6 deletions

View file

@ -60,7 +60,9 @@ class Html extends ConsumerWidget {
"a" => "a" =>
element.attributes["href"]?.mention == null element.attributes["href"]?.mention == null
? null ? null
: InlineCustomWidget(child: MentionChip(element.text)), : InlineCustomWidget(
child: MentionChip(element.attributes["href"]!),
),
"img" => "img" =>
src == null src == null

View file

@ -5,19 +5,20 @@ import "package:nexus/helpers/extensions/link_to_mention.dart";
import "package:nexus/helpers/extensions/show_user_popover.dart"; import "package:nexus/helpers/extensions/show_user_popover.dart";
class MentionChip extends ConsumerWidget { class MentionChip extends ConsumerWidget {
final String label; final String content;
const MentionChip(this.label, {super.key}); const MentionChip(this.content, {super.key});
@override @override
Widget build(BuildContext context, WidgetRef ref) { Widget build(BuildContext context, WidgetRef ref) {
final membership = label.mention.startsWith("@") == true final membership = content.mention.startsWith("@") == true
? ref ? ref
.watch(UserController.provider(label.mention)) .watch(UserController.provider(content.mention))
.whenOrNull(data: (data) => data) .whenOrNull(data: (data) => data)
: null; : null;
return InkWell( return InkWell(
onTapUp: (details) { onTapUp: (details) {
content.mention;
if (membership != null) { if (membership != null) {
context.showUserPopover( context.showUserPopover(
membership, membership,
@ -29,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}") ??
label.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,