From 766be8142e69e4511d5b1ced28d558ae8a78bd63 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Mon, 24 Jul 2023 13:04:21 +0200 Subject: [PATCH] ffi: Make fetch_members cancellable --- bindings/matrix-sdk-ffi/src/room.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/room.rs b/bindings/matrix-sdk-ffi/src/room.rs index 95c8d5bca..9a7327093 100644 --- a/bindings/matrix-sdk-ffi/src/room.rs +++ b/bindings/matrix-sdk-ffi/src/room.rs @@ -157,18 +157,15 @@ impl Room { }); } - pub fn fetch_members(&self) { - let timeline = match &*RUNTIME.block_on(self.timeline.read()) { - Some(t) => Arc::clone(t), - None => { - error!("Timeline not set up, can't fetch members"); - return; - } - }; + pub fn fetch_members(&self) -> Result, ClientError> { + let timeline = RUNTIME + .block_on(self.timeline.read()) + .clone() + .context("Timeline not set up, can't fetch members")?; - RUNTIME.spawn(async move { + Ok(Arc::new(TaskHandle::new(RUNTIME.spawn(async move { timeline.fetch_members().await; - }); + })))) } pub fn display_name(&self) -> Result {