fix(ffi): RoomListItem::full_room returns a Room with a Timeline.

This commit is contained in:
Ivan Enderlin
2023-06-15 09:26:33 +02:00
parent 23d5655901
commit 6e1de8a5ee
2 changed files with 11 additions and 5 deletions

View File

@@ -241,7 +241,7 @@ impl Room {
let listener: Arc<dyn TimelineListener> = listener.into();
let timeline_stream =
Arc::new(TaskHandle::new(RUNTIME.spawn(timeline_stream.for_each(move |diff| {
TaskHandle::new(RUNTIME.spawn(timeline_stream.for_each(move |diff| {
let listener = listener.clone();
let fut = RUNTIME.spawn_blocking(move || {
listener.on_update(Arc::new(TimelineDiff::new(diff)))
@@ -252,11 +252,11 @@ impl Room {
error!("Timeline listener error: {e}");
}
}
}))));
})));
RoomTimelineListenerResult {
items: timeline_items.into_iter().map(TimelineItem::from_arc).collect(),
items_stream: timeline_stream,
items_stream: Arc::new(timeline_stream),
}
})
}

View File

@@ -1,4 +1,7 @@
use std::{fmt::Debug, sync::Arc};
use std::{
fmt::Debug,
sync::{Arc, RwLock},
};
use eyeball_im::VectorDiff;
use futures_util::{pin_mut, StreamExt};
@@ -203,7 +206,10 @@ impl RoomListItem {
}
fn full_room(&self) -> Arc<Room> {
Arc::new(Room::new(self.inner.inner_room().clone()))
Arc::new(Room::with_timeline(
self.inner.inner_room().clone(),
Arc::new(RwLock::new(Some(RUNTIME.block_on(async { self.inner.timeline().await })))),
))
}
fn subscribe(&self, settings: Option<RoomSubscription>) {