diff --git a/crates/matrix-sdk-ui/src/timeline/mod.rs b/crates/matrix-sdk-ui/src/timeline/mod.rs index 50719bf72..e4c10c13a 100644 --- a/crates/matrix-sdk-ui/src/timeline/mod.rs +++ b/crates/matrix-sdk-ui/src/timeline/mod.rs @@ -52,7 +52,7 @@ use ruma::{ serde::Raw, EventId, MilliSecondsSinceUnixEpoch, OwnedEventId, OwnedUserId, RoomVersionId, UserId, }; -use subscriber::TimelineStream; +use subscriber::TimelineWithDropHandle; use thiserror::Error; use tracing::{error, instrument, trace, warn}; @@ -277,7 +277,7 @@ impl Timeline { &self, ) -> (Vector>, impl Stream>>>) { let (items, stream) = self.controller.subscribe_batched().await; - let stream = TimelineStream::new(stream, self.drop_handle.clone()); + let stream = TimelineWithDropHandle::new(stream, self.drop_handle.clone()); (items, stream) } @@ -811,7 +811,7 @@ impl Timeline { f: impl Fn(Arc) -> Option, ) -> (Vector, impl Stream>) { let (items, stream) = self.controller.subscribe_filter_map(f).await; - let stream = TimelineStream::new(stream, self.drop_handle.clone()); + let stream = TimelineWithDropHandle::new(stream, self.drop_handle.clone()); (items, stream) } } diff --git a/crates/matrix-sdk-ui/src/timeline/subscriber.rs b/crates/matrix-sdk-ui/src/timeline/subscriber.rs index 6673a4b1b..e23c90b0e 100644 --- a/crates/matrix-sdk-ui/src/timeline/subscriber.rs +++ b/crates/matrix-sdk-ui/src/timeline/subscriber.rs @@ -24,20 +24,23 @@ use pin_project_lite::pin_project; use super::TimelineDropHandle; pin_project! { - pub(super) struct TimelineStream { + /// A stream that wraps a [`TimelineDropHandle`] so that the `Timeline` + /// isn't dropped until the `Stream` is dropped. + pub(super) struct TimelineWithDropHandle { #[pin] inner: S, drop_handle: Arc, } } -impl TimelineStream { - pub fn new(inner: S, drop_handle: Arc) -> Self { +impl TimelineWithDropHandle { + /// Create a new [`WithTimelineDropHandle`]. + pub(super) fn new(inner: S, drop_handle: Arc) -> Self { Self { inner, drop_handle } } } -impl Stream for TimelineStream +impl Stream for TimelineWithDropHandle where S: Stream, {