Skip to content

Commit

Permalink
fix broadcast group stream bug (#1613)
Browse files Browse the repository at this point in the history
  • Loading branch information
insipx authored Feb 7, 2025
1 parent 458bdaf commit b6f090b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions xmtp_mls/src/subscriptions/stream_conversations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,23 @@ impl Stream for BroadcastGroupStream {

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
use std::task::Poll::*;
let this = self.project();
if let Some(event) = ready!(this.inner.poll_next(cx)) {
if let Some(group) =
xmtp_common::optify!(event, "Missed messages due to event queue lag")
.and_then(LocalEvents::group_filter)
{
Ready(Some(Ok(WelcomeOrGroup::Group(group))))
let mut this = self.project();
// loop until the inner stream returns:
// - Ready with a group
// - Ready(None) - stream ended
// ignore None values, since it is not a group, but may indicate more values in the stream
// itself
loop {
if let Some(event) = ready!(this.inner.as_mut().poll_next(cx)) {
if let Some(group) =
xmtp_common::optify!(event, "Missed messages due to event queue lag")
.and_then(LocalEvents::group_filter)
{
return Ready(Some(Ok(WelcomeOrGroup::Group(group))));
}
} else {
Pending
return Ready(None);
}
} else {
Ready(None)
}
}
}
Expand Down

0 comments on commit b6f090b

Please sign in to comment.