From 9f91135572fa5a02e0d443277537d4f5673740f4 Mon Sep 17 00:00:00 2001 From: Kieran Date: Mon, 19 May 2025 16:41:26 +0100 Subject: [PATCH] fix: hide events from before start of stream --- lib/widgets/chat.dart | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/widgets/chat.dart b/lib/widgets/chat.dart index a67127e..432b844 100644 --- a/lib/widgets/chat.dart +++ b/lib/widgets/chat.dart @@ -39,15 +39,19 @@ class ChatWidget extends StatelessWidget { filters: filters, builder: (ctx, state) { final now = DateTime.now().millisecondsSinceEpoch / 1000; - final firstPassEvents = (state ?? []).where( - (e) => switch (e.kind) { - 1314 => muteLists.contains( - e.pubKey, - ), // filter timeouts to only people allowed to mute - // TODO: check other kinds are valid for this stream - _ => true, - }, - ); + final firstPassEvents = + (state ?? []) + .where( + (e) => switch (e.kind) { + 1314 => + muteLists.contains(e.pubKey) && + double.parse(e.getFirstTag("expiration")!) > + now, // filter timeouts to only people allowed to mute + // TODO: check other kinds are valid for this stream + _ => true, + }, + ) + .toList(); final mutedPubkeys = firstPassEvents .where( @@ -74,6 +78,8 @@ class ChatWidget extends StatelessWidget { return muteLists.contains(author) || // cant mute self or host !mutedPubkeys.contains(author); }) + // filter events that are created before stream start time + .where((e) => e.createdAt >= (stream.info.starts ?? 0)) .sortedBy((e) => e.createdAt) .reversed .toList(); @@ -141,7 +147,7 @@ class ChatWidget extends StatelessWidget { if (stream.info.status == StreamStatus.live && !isChatDisabled) WriteMessageWidget(stream: stream), if (stream.info.status == StreamStatus.live && isChatDisabled) - _chatDisabled(filteredChat), + _chatDisabled(firstPassEvents), if (stream.info.status == StreamStatus.ended) Container( padding: EdgeInsets.all(8),