From 993dc8264a740140f308398471a5d05c77071337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Wed, 13 May 2020 12:26:07 +0200 Subject: [PATCH] base: Return early if we get a duplicate sync response. --- matrix_sdk_base/src/client.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/matrix_sdk_base/src/client.rs b/matrix_sdk_base/src/client.rs index 4a454878..f48c764a 100644 --- a/matrix_sdk_base/src/client.rs +++ b/matrix_sdk_base/src/client.rs @@ -633,6 +633,13 @@ impl BaseClient { &self, response: &mut api::sync::sync_events::Response, ) -> Result<()> { + // The server might respond multiple times with the same sync token, in + // that case we already received this response and there's nothing to + // do. + if self.sync_token.read().await.as_ref() == Some(&response.next_batch) { + return Ok(()); + } + *self.sync_token.write().await = Some(response.next_batch.clone()); #[cfg(feature = "encryption")]