better link support

This commit is contained in:
Henry Hiles 2025-11-23 13:43:25 -05:00
commit 7890add93c
No known key found for this signature in database

View file

@ -112,7 +112,8 @@ class RoomChat extends HookConsumerWidget {
builders: Builders(
chatAnimatedListBuilder: (_, itemBuilder) =>
ChatAnimatedList(
itemBuilder: itemBuilder,
itemBuilder:
itemBuilder, // TODO: Load earlier
onEndReached: notifier.loadOlder,
onStartReached: () => notifier.markRead(),
),
@ -130,7 +131,24 @@ class RoomChat extends HookConsumerWidget {
MessageGroupStatus? groupStatus,
}) => FlyerChatTextMessage(
customWidget: HtmlWidget(
message.metadata?["formatted"],
message.metadata?["formatted"].replaceAllMapped(
RegExp(regexLink, unicode: true),
(match) {
final full = match.group(0)!;
// If no protocol is present, add https://
final hasProtocol =
full.startsWith("http://") ||
full.startsWith("https://") ||
full.startsWith("ftp://");
final url = hasProtocol
? full
: "https://$full";
return "<a href=\"$url\">$full</a>";
},
),
customWidgetBuilder: (element) {
if (element.localName == "mx-reply") {
return SizedBox.shrink();