From bf47d2bcee6e1bc71530a23264eae63a7af84aae Mon Sep 17 00:00:00 2001 From: Mikko Rantanen Date: Mon, 5 Aug 2024 07:29:52 +0300 Subject: [PATCH] Filter asynchronous events (#466) --- src/eventloop.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/eventloop.rs b/src/eventloop.rs index cc34efbadb8..1a3484dd7d4 100644 --- a/src/eventloop.rs +++ b/src/eventloop.rs @@ -441,12 +441,16 @@ where self.given = false; } - if let Some(data) = self.receiver.get_shared_async().await { + while let Some(data) = self.receiver.get_shared_async().await { + if Some(data.source) != D::source() { + self.receiver.done(); + continue; + } self.given = true; - Ok(D::deserialize(data)) - } else { - Err(EspError::from_infallible::()) + return Ok(D::deserialize(data)); } + + Err(EspError::from_infallible::()) } }