mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 13:40:55 -04:00
ffi: Remove async from a few functions
… to hopefully work around current issues.
This commit is contained in:
committed by
Jonas Platte
parent
c2a8fbd3c9
commit
fc3883d08e
@@ -226,39 +226,36 @@ impl Room {
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn add_timeline_listener(
|
||||
pub fn add_timeline_listener(
|
||||
self: Arc<Self>,
|
||||
listener: Box<dyn TimelineListener>,
|
||||
) -> RoomTimelineListenerResult {
|
||||
RUNTIME
|
||||
.spawn(async move {
|
||||
let timeline = self
|
||||
.timeline
|
||||
.write()
|
||||
.await
|
||||
.get_or_insert_with(|| {
|
||||
let timeline = RUNTIME.block_on(self.inner.timeline());
|
||||
Arc::new(timeline)
|
||||
})
|
||||
.clone();
|
||||
RUNTIME.block_on(async move {
|
||||
let timeline = self
|
||||
.timeline
|
||||
.write()
|
||||
.await
|
||||
.get_or_insert_with(|| {
|
||||
let timeline = RUNTIME.block_on(self.inner.timeline());
|
||||
Arc::new(timeline)
|
||||
})
|
||||
.clone();
|
||||
|
||||
let (timeline_items, timeline_stream) = timeline.subscribe().await;
|
||||
let (timeline_items, timeline_stream) = timeline.subscribe().await;
|
||||
|
||||
let timeline_stream = TaskHandle::new(RUNTIME.spawn(async move {
|
||||
pin_mut!(timeline_stream);
|
||||
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)));
|
||||
}
|
||||
}));
|
||||
|
||||
RoomTimelineListenerResult {
|
||||
items: timeline_items.into_iter().map(TimelineItem::from_arc).collect(),
|
||||
items_stream: Arc::new(timeline_stream),
|
||||
while let Some(diff) = timeline_stream.next().await {
|
||||
listener.on_update(Arc::new(TimelineDiff::new(diff)));
|
||||
}
|
||||
})
|
||||
.await
|
||||
.unwrap()
|
||||
}));
|
||||
|
||||
RoomTimelineListenerResult {
|
||||
items: timeline_items.into_iter().map(TimelineItem::from_arc).collect(),
|
||||
items_stream: Arc::new(timeline_stream),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn subscribe_to_back_pagination_status(
|
||||
@@ -960,13 +957,10 @@ impl SendAttachmentJoinHandle {
|
||||
}
|
||||
}
|
||||
|
||||
#[uniffi::export(async_runtime = "tokio")]
|
||||
#[uniffi::export]
|
||||
impl SendAttachmentJoinHandle {
|
||||
pub async fn join(self: Arc<Self>) -> Result<(), RoomError> {
|
||||
RUNTIME
|
||||
.spawn(async move { (&mut *self.join_hdl.lock().await).await.unwrap() })
|
||||
.await
|
||||
.unwrap()
|
||||
pub fn join(self: Arc<Self>) -> Result<(), RoomError> {
|
||||
RUNTIME.block_on(async move { (&mut *self.join_hdl.lock().await).await.unwrap() })
|
||||
}
|
||||
|
||||
pub fn cancel(&self) {
|
||||
|
||||
Reference in New Issue
Block a user