Skip to content

Commit 5acaaf5

Browse files
committed
fix(ffi): call the back-pagination status callback immediately
1 parent 156501d commit 5acaaf5

File tree

1 file changed

+7
-3
lines changed
  • bindings/matrix-sdk-ffi/src/timeline

1 file changed

+7
-3
lines changed

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,14 @@ impl Timeline {
256256
.await
257257
.context("can't subscribe to the back-pagination status on a focused timeline")?;
258258

259-
Ok(Arc::new(TaskHandle::new(get_runtime_handle().spawn(async move {
260-
// Send the current state even if it hasn't changed right away.
261-
listener.on_update(initial);
259+
// Send the current state even if it hasn't changed right away.
260+
//
261+
// Note: don't do it in the spawned function, so that the caller is immediately
262+
// aware of the current state, and this doesn't depend on the async runtime
263+
// having an available worker
264+
listener.on_update(initial);
262265

266+
Ok(Arc::new(TaskHandle::new(get_runtime_handle().spawn(async move {
263267
while let Some(status) = subscriber.next().await {
264268
listener.on_update(status);
265269
}

0 commit comments

Comments
 (0)