Skip to content

Commit e974ea8

Browse files
committed
task(ui): Apply the Skip higher-order stream for the Timeline.
This patch applies the `Skip` higher-order stream on the `Timeline` subscriber. The method `TimelineController::subscribe_batched` is renamed `subscribe_batched_and_limited` at the same time. The `Skip` stream uses the `TimelineMetadata::subscriber_skip_count` observable value as the `count_stream`. The initial count value is 0. No test needs to be changed so far.
1 parent 357d77b commit e974ea8

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

Cargo.lock

+4-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ as_variant = "1.2.0"
3333
base64 = "0.22.1"
3434
byteorder = "1.5.0"
3535
chrono = "0.4.38"
36-
eyeball = { version = "0.8.8", features = ["tracing"] }
37-
eyeball-im = { version = "0.6.0", features = ["tracing"] }
38-
eyeball-im-util = "0.8.0"
36+
eyeball = { path = "../eyeball/eyeball/", features = ["tracing"] }
37+
eyeball-im = { path = "../eyeball/eyeball-im", features = ["tracing"] }
38+
eyeball-im-util = { path = "../eyeball/eyeball-im-util" }
3939
futures-core = "0.3.31"
4040
futures-executor = "0.3.21"
4141
futures-util = "0.3.31"
@@ -44,7 +44,7 @@ growable-bloom-filter = "2.1.1"
4444
hkdf = "0.12.4"
4545
hmac = "0.12.1"
4646
http = "1.1.0"
47-
imbl = "4.0.1"
47+
imbl = "3.0.0"
4848
indexmap = "2.6.0"
4949
insta = { version = "1.41.1", features = ["json"] }
5050
itertools = "0.13.0"

crates/matrix-sdk-ui/src/timeline/controller/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,15 @@ impl<P: RoomDataProvider> TimelineController<P> {
496496
(state.items.clone_items(), state.items.subscribe().into_stream())
497497
}
498498

499-
pub(super) async fn subscribe_batched(
499+
pub(super) async fn subscribe_batched_and_limited(
500500
&self,
501501
) -> (Vector<Arc<TimelineItem>>, impl Stream<Item = Vec<VectorDiff<Arc<TimelineItem>>>>) {
502502
let state = self.state.read().await;
503-
state.items.subscribe().into_values_and_batched_stream()
503+
state
504+
.items
505+
.subscribe()
506+
.into_values_and_batched_stream()
507+
.dynamic_skip_with_initial_count(0, state.meta.subscriber_skip_count.subscribe())
504508
}
505509

506510
pub(super) async fn subscribe_filter_map<U, F>(

crates/matrix-sdk-ui/src/timeline/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl Timeline {
276276
pub async fn subscribe(
277277
&self,
278278
) -> (Vector<Arc<TimelineItem>>, impl Stream<Item = Vec<VectorDiff<Arc<TimelineItem>>>>) {
279-
let (items, stream) = self.controller.subscribe_batched().await;
279+
let (items, stream) = self.controller.subscribe_batched_and_limited().await;
280280
let stream = WithTimelineDropHandle::new(stream, self.drop_handle.clone());
281281
(items, stream)
282282
}

crates/matrix-sdk-ui/src/timeline/tests/basic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ async fn test_replace_with_initial_events_when_batched() {
461461
)
462462
.await;
463463

464-
let (items, mut stream) = timeline.controller.subscribe_batched().await;
464+
let (items, mut stream) = timeline.controller.subscribe_batched_and_limited().await;
465465
assert_eq!(items.len(), 2);
466466
assert!(items[0].is_date_divider());
467467
assert_eq!(items[1].as_event().unwrap().content().as_message().unwrap().body(), "hey");

0 commit comments

Comments
 (0)