Send cursors instantly

This commit is contained in:
Andras Schmelczer 2025-06-08 11:32:41 +01:00
parent 57b2b76932
commit f4c77ddd25
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
5 changed files with 87 additions and 9 deletions

View file

@ -48,6 +48,10 @@ impl Cursors {
device_id: device_id.to_string(),
cursors: document_to_cursors,
}));
drop(vault_to_cursors); // Explicitly drop the lock before broadcasting to avoid deadlock
self.broadcast_cursors().await;
}
pub async fn get_cursors(&self, vault_id: &VaultId) -> Vec<ClientCursors> {
@ -73,7 +77,6 @@ impl Cursors {
async fn run_backround_task(&self) {
loop {
self.remove_expired_cursors().await;
self.broadcast_cursors().await;
tokio::time::sleep(self.config.cursor_broadcast_interval).await;
}
}