mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-19 14:19:06 -04:00
ffi: Use batched timeline subscription
This commit is contained in:
committed by
Jonas Platte
parent
9a8c6249bb
commit
640e5fbacf
@@ -241,13 +241,15 @@ impl Room {
|
||||
})
|
||||
.clone();
|
||||
|
||||
let (timeline_items, timeline_stream) = timeline.subscribe().await;
|
||||
let (timeline_items, timeline_stream) = timeline.subscribe_batched().await;
|
||||
|
||||
let timeline_stream = TaskHandle::new(RUNTIME.spawn(async move {
|
||||
pin_mut!(timeline_stream);
|
||||
|
||||
while let Some(diff) = timeline_stream.next().await {
|
||||
listener.on_update(Arc::new(TimelineDiff::new(diff)));
|
||||
while let Some(diffs) = timeline_stream.next().await {
|
||||
listener.on_update(
|
||||
diffs.into_iter().map(|d| Arc::new(TimelineDiff::new(d))).collect(),
|
||||
);
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn message_event_content_from_markdown(md: String) -> Arc<RoomMessageEventCo
|
||||
|
||||
#[uniffi::export(callback_interface)]
|
||||
pub trait TimelineListener: Sync + Send {
|
||||
fn on_update(&self, diff: Arc<TimelineDiff>);
|
||||
fn on_update(&self, diff: Vec<Arc<TimelineDiff>>);
|
||||
}
|
||||
|
||||
#[derive(Clone, uniffi::Object)]
|
||||
|
||||
Reference in New Issue
Block a user