Skip to content

Commit

Permalink
fix(ffi): RoomListItem::full_room returns a Room with a Timeline.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hywan committed Jun 15, 2023
1 parent 23d5655 commit 6e1de8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions bindings/matrix-sdk-ffi/src/room.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand All @@ -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),
}
})
}
Expand Down
10 changes: 8 additions & 2 deletions bindings/matrix-sdk-ffi/src/room_list.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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>) {
Expand Down

0 comments on commit 6e1de8a

Please sign in to comment.