fix: replace Nip19.decode to bech32ToHex (TLV decode)

This commit is contained in:
2025-05-12 15:58:13 +01:00
parent 026b2eb85c
commit 77d70e164b
8 changed files with 85 additions and 11 deletions

View File

@ -5,6 +5,7 @@ import 'package:ndk/ndk.dart';
import 'package:ndk/shared/nips/nip19/nip19.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:zap_stream_flutter/theme.dart';
import 'package:zap_stream_flutter/utils.dart';
import 'package:zap_stream_flutter/widgets/profile.dart';
/// Converts a nostr note text containing links
@ -62,10 +63,15 @@ InlineSpan _buildProfileOrNoteSpan(String word) {
cleanedWord.startsWith('note') || cleanedWord.startsWith('nevent');
if (isProfile) {
return _inlineMention(Nip19.decode(cleanedWord));
final hexKey = bech32ToHex(cleanedWord);
if (hexKey.isNotEmpty) {
return _inlineMention(hexKey);
} else {
return TextSpan(text: "@$cleanedWord");
}
}
if (isNote) {
final eventId = Nip19.decode(cleanedWord);
final eventId = bech32ToHex(cleanedWord);
return TextSpan(text: eventId, style: TextStyle(color: PRIMARY_1));
} else {
return TextSpan(text: word);