From d1926ebdc9648a2445c200f991948ed530a4824b Mon Sep 17 00:00:00 2001 From: Demmie <2e3s19@gmail.com> Date: Wed, 12 Jun 2024 02:11:16 -0400 Subject: [PATCH] Avoid creation of different idle events The events are identified by timestamp which becomes different after +1ms. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- watchers/src/watchers/idle.rs | 8 +++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b9e34b7..11a2959 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -503,7 +503,7 @@ dependencies = [ [[package]] name = "awatcher" -version = "0.2.7" +version = "0.2.8" dependencies = [ "anyhow", "aw-datastore", @@ -4031,7 +4031,7 @@ checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "watchers" -version = "0.2.7" +version = "0.2.8" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index b07bd91..b60fb93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ image = { version = "0.25.1" } members = ["watchers"] [workspace.package] -version = "0.2.7" +version = "0.2.8" [workspace.dependencies] anyhow = "1.0.83" diff --git a/watchers/src/watchers/idle.rs b/watchers/src/watchers/idle.rs index 7c8f89b..86498e3 100644 --- a/watchers/src/watchers/idle.rs +++ b/watchers/src/watchers/idle.rs @@ -82,12 +82,9 @@ impl State { .await?; // ping with timestamp+1ms with the next event (to ensure the latest event gets retrieved by get_event) + self.last_input_time += Duration::milliseconds(1); client - .ping( - true, - self.last_input_time + Duration::milliseconds(1), - now - self.last_input_time, - ) + .ping(true, self.last_input_time, now - self.last_input_time) .await } else { debug!("Reporting as no longer idle"); @@ -95,6 +92,7 @@ impl State { client .ping(true, self.last_input_time, Duration::zero()) .await?; + client .ping( false,