Skip to content

Commit

Permalink
chore(ui): Remove Timeline::subscribe.
Browse files Browse the repository at this point in the history
This patch removes `Timeline::subscribe`. There is
`Timeline::subscribe_batched`, which is the only useful API.
`subscribe` was only used by our tests, and `matrix-sdk-ffi` uses
`subscribe_batched` only.
  • Loading branch information
Hywan committed Jan 22, 2025
1 parent 4684cfb commit 1d83d42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
5 changes: 3 additions & 2 deletions crates/matrix-sdk-ui/src/timeline/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ use eyeball_im_util::vector::VectorObserverExt;
use futures_core::Stream;
use imbl::Vector;
#[cfg(test)]
use matrix_sdk::crypto::OlmMachine;
use matrix_sdk::{crypto::OlmMachine, SendOutsideWasm};
use matrix_sdk::{
deserialized_responses::{SyncTimelineEvent, TimelineEventKind as SdkTimelineEventKind},
event_cache::{paginator::Paginator, RoomEventCache},
send_queue::{
LocalEcho, LocalEchoContent, RoomSendQueueUpdate, SendHandle, SendReactionHandle,
},
Result, Room, SendOutsideWasm,
Result, Room,
};
use ruma::{
api::client::receipt::create_receipt::v3::ReceiptType as SendReceiptType,
Expand Down Expand Up @@ -477,6 +477,7 @@ impl<P: RoomDataProvider> TimelineController<P> {
self.state.read().await.items.clone_items()
}

#[cfg(test)]
pub(super) async fn subscribe(
&self,
) -> (
Expand Down
17 changes: 2 additions & 15 deletions crates/matrix-sdk-ui/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,23 +266,10 @@ impl Timeline {
}
}

/// Get the current timeline items, and a stream of changes.
///
/// You can poll this stream to receive updates. See
/// [`futures_util::StreamExt`] for a high-level API on top of [`Stream`].
pub async fn subscribe(
&self,
) -> (Vector<Arc<TimelineItem>>, impl Stream<Item = VectorDiff<Arc<TimelineItem>>>) {
let (items, stream) = self.controller.subscribe().await;
let stream = TimelineStream::new(stream, self.drop_handle.clone());
(items, stream)
}

/// Get the current timeline items, and a batched stream of changes.
///
/// In contrast to [`subscribe`](Self::subscribe), this stream can yield
/// multiple diffs at once. The batching is done such that no arbitrary
/// delays are added.
/// This stream can yield multiple diffs at once. The batching is done such
/// that no arbitrary delays are added.
pub async fn subscribe_batched(
&self,
) -> (Vector<Arc<TimelineItem>>, impl Stream<Item = Vec<VectorDiff<Arc<TimelineItem>>>>) {
Expand Down

0 comments on commit 1d83d42

Please sign in to comment.