shows room but not really
This commit is contained in:
parent
85d96b80bc
commit
a28bced44d
23 changed files with 885 additions and 805 deletions
7
lib/helpers/extensions/get_headers.dart
Normal file
7
lib/helpers/extensions/get_headers.dart
Normal 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;
|
||||
}
|
||||
40
lib/helpers/extensions/link_to_mention.dart
Normal file
40
lib/helpers/extensions/link_to_mention.dart
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue