From 5acaaf5865d2940903f8511ec99ab9602815f967 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Wed, 19 Mar 2025 17:56:36 +0100 Subject: [PATCH] fix(ffi): call the back-pagination status callback immediately --- bindings/matrix-sdk-ffi/src/timeline/mod.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bindings/matrix-sdk-ffi/src/timeline/mod.rs b/bindings/matrix-sdk-ffi/src/timeline/mod.rs index fb28b48cd..468dc395c 100644 --- a/bindings/matrix-sdk-ffi/src/timeline/mod.rs +++ b/bindings/matrix-sdk-ffi/src/timeline/mod.rs @@ -256,10 +256,14 @@ impl Timeline { .await .context("can't subscribe to the back-pagination status on a focused timeline")?; - Ok(Arc::new(TaskHandle::new(get_runtime_handle().spawn(async move { - // Send the current state even if it hasn't changed right away. - listener.on_update(initial); + // Send the current state even if it hasn't changed right away. + // + // Note: don't do it in the spawned function, so that the caller is immediately + // aware of the current state, and this doesn't depend on the async runtime + // having an available worker + listener.on_update(initial); + Ok(Arc::new(TaskHandle::new(get_runtime_handle().spawn(async move { while let Some(status) = subscriber.next().await { listener.on_update(status); }