From f570f4c1f220822edd1907b68a2200b01346c69a Mon Sep 17 00:00:00 2001 From: Kieran Date: Sat, 7 Jun 2025 10:48:29 +0100 Subject: [PATCH] fix: range error --- lib/utils.dart | 2 +- lib/widgets/chat_raid.dart | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/utils.dart b/lib/utils.dart index 06d572b..7628835 100644 --- a/lib/utils.dart +++ b/lib/utils.dart @@ -233,7 +233,7 @@ StreamInfo extractStreamInfo(Nip01Event ev) { String getHost(Nip01Event ev) { return ev.tags.firstWhere( - (t) => t[0] == "p" && t.length > 2 && t[3] == "host", + (t) => t[0] == "p" && t.length > 3 && t[3] == "host", orElse: () => ["p", ev.pubKey], // fake p tag with event pubkey )[1]; } diff --git a/lib/widgets/chat_raid.dart b/lib/widgets/chat_raid.dart index f384d93..b8a6214 100644 --- a/lib/widgets/chat_raid.dart +++ b/lib/widgets/chat_raid.dart @@ -33,11 +33,15 @@ class __ChatRaidMessage extends State _from = widget.event.tags.firstWhereOrNull( - (t) => t[0] == "a" && (t[3] == "from" || t[3] == "root"), + (t) => + t[0] == "a" && t.length > 3 && (t[3] == "from" || t[3] == "root"), )?[1]; _to = widget.event.tags.firstWhereOrNull( - (t) => t[0] == "a" && (t[3] == "to" || t[3] == "mention"), + (t) => + t[0] == "a" && + t.length > 3 && + (t[3] == "to" || t[3] == "mention"), )?[1]; _isRaiding = _from == widget.stream.aTag; final isAutoRaid =