fix: hide events from before start of stream

This commit is contained in:
2025-05-19 16:41:26 +01:00
parent a5736aa3d3
commit 9f91135572

View File

@ -39,15 +39,19 @@ class ChatWidget extends StatelessWidget {
filters: filters, filters: filters,
builder: (ctx, state) { builder: (ctx, state) {
final now = DateTime.now().millisecondsSinceEpoch / 1000; final now = DateTime.now().millisecondsSinceEpoch / 1000;
final firstPassEvents = (state ?? []).where( final firstPassEvents =
(e) => switch (e.kind) { (state ?? [])
1314 => muteLists.contains( .where(
e.pubKey, (e) => switch (e.kind) {
), // filter timeouts to only people allowed to mute 1314 =>
// TODO: check other kinds are valid for this stream muteLists.contains(e.pubKey) &&
_ => true, 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 = final mutedPubkeys =
firstPassEvents firstPassEvents
.where( .where(
@ -74,6 +78,8 @@ class ChatWidget extends StatelessWidget {
return muteLists.contains(author) || // cant mute self or host return muteLists.contains(author) || // cant mute self or host
!mutedPubkeys.contains(author); !mutedPubkeys.contains(author);
}) })
// filter events that are created before stream start time
.where((e) => e.createdAt >= (stream.info.starts ?? 0))
.sortedBy((e) => e.createdAt) .sortedBy((e) => e.createdAt)
.reversed .reversed
.toList(); .toList();
@ -141,7 +147,7 @@ class ChatWidget extends StatelessWidget {
if (stream.info.status == StreamStatus.live && !isChatDisabled) if (stream.info.status == StreamStatus.live && !isChatDisabled)
WriteMessageWidget(stream: stream), WriteMessageWidget(stream: stream),
if (stream.info.status == StreamStatus.live && isChatDisabled) if (stream.info.status == StreamStatus.live && isChatDisabled)
_chatDisabled(filteredChat), _chatDisabled(firstPassEvents),
if (stream.info.status == StreamStatus.ended) if (stream.info.status == StreamStatus.ended)
Container( Container(
padding: EdgeInsets.all(8), padding: EdgeInsets.all(8),