shows room but not really

This commit is contained in:
Henry Hiles 2026-01-27 19:09:43 +00:00
commit 5f96c8e57f
No known key found for this signature in database
23 changed files with 885 additions and 805 deletions

View file

@ -0,0 +1,7 @@
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:nexus/controllers/header_controller.dart";
extension GetHeaders on WidgetRef {
Map<String, String> get headers =>
watch(HeaderController.provider).requireValue;
}

View file

@ -0,0 +1,40 @@
extension LinkToMention on String {
/// Extracts a Matrix identifier from this string.
///
/// Supports:
/// - https://matrix.to/#/...
/// - matrix:roomid/...
/// - matrix:r/...
/// - matrix:u/...
///
/// Returns the decoded identifier (e.g. "#room:matrix.org")
/// or null if this is not a Matrix link.
String? get mention {
final trimmed = trim();
final matrixTo = RegExp(
r"^https?://matrix\.to/#/([^/?#]+)",
caseSensitive: false,
);
final matrixToMatch = matrixTo.firstMatch(trimmed);
if (matrixToMatch != null) {
return Uri.decodeComponent(matrixToMatch.group(1)!);
}
if (trimmed.toLowerCase().startsWith("matrix:")) {
try {
final uri = Uri.parse(trimmed);
if (uri.pathSegments.isNotEmpty) {
final identifier = uri.pathSegments.last;
if (identifier.isNotEmpty) {
return Uri.decodeComponent(identifier);
}
}
} catch (_) {}
}
return null;
}
}