refactor(ui): Rename TimelineStream to TimelineWithDropHandle.

This patch renames `TimelineStream` to `TimelineWithDropHandle`, as the
former name was too vague and was not clarify what the type was doing.
The new name makes it clear that it attaches a `TimelineDropHandle` to a
subscriber (since it is part of the `subscriber` module!).
This commit is contained in:
Ivan Enderlin
2025-01-29 08:47:26 +01:00
parent 892cb9116c
commit d85d6cfbca
2 changed files with 10 additions and 7 deletions

View File

@@ -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<Arc<TimelineItem>>, impl Stream<Item = Vec<VectorDiff<Arc<TimelineItem>>>>) {
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<TimelineItem>) -> Option<U>,
) -> (Vector<U>, impl Stream<Item = VectorDiff<U>>) {
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)
}
}

View File

@@ -24,20 +24,23 @@ use pin_project_lite::pin_project;
use super::TimelineDropHandle;
pin_project! {
pub(super) struct TimelineStream<S> {
/// A stream that wraps a [`TimelineDropHandle`] so that the `Timeline`
/// isn't dropped until the `Stream` is dropped.
pub(super) struct TimelineWithDropHandle<S> {
#[pin]
inner: S,
drop_handle: Arc<TimelineDropHandle>,
}
}
impl<S> TimelineStream<S> {
pub fn new(inner: S, drop_handle: Arc<TimelineDropHandle>) -> Self {
impl<S> TimelineWithDropHandle<S> {
/// Create a new [`WithTimelineDropHandle`].
pub(super) fn new(inner: S, drop_handle: Arc<TimelineDropHandle>) -> Self {
Self { inner, drop_handle }
}
}
impl<S> Stream for TimelineStream<S>
impl<S> Stream for TimelineWithDropHandle<S>
where
S: Stream,
{