@@ -38,9 +38,10 @@ impl State {
38
38
seconds_since_input : u32 ,
39
39
client : & Arc < ReportClient > ,
40
40
) -> anyhow:: Result < ( ) > {
41
+ let now = Utc :: now ( ) ;
41
42
let time_since_input = Duration :: seconds ( i64:: from ( seconds_since_input) ) ;
42
43
43
- self . last_input_time = Utc :: now ( ) - time_since_input;
44
+ self . last_input_time = now - time_since_input;
44
45
45
46
if self . is_idle
46
47
&& u64:: from ( seconds_since_input) < self . idle_timeout . num_seconds ( ) . try_into ( ) . unwrap ( )
@@ -56,9 +57,7 @@ impl State {
56
57
self . is_changed = true ;
57
58
}
58
59
59
- self . send_ping ( client) . await ?;
60
-
61
- Ok ( ( ) )
60
+ self . send_ping ( now, client) . await
62
61
}
63
62
64
63
pub async fn send_reactive ( & mut self , client : & Arc < ReportClient > ) -> anyhow:: Result < ( ) > {
@@ -67,12 +66,10 @@ impl State {
67
66
self . last_input_time = now;
68
67
}
69
68
70
- self . send_ping ( client) . await
69
+ self . send_ping ( now , client) . await
71
70
}
72
71
73
- async fn send_ping ( & mut self , client : & Arc < ReportClient > ) -> anyhow:: Result < ( ) > {
74
- let now = Utc :: now ( ) ;
75
-
72
+ async fn send_ping ( & mut self , now : DateTime < Utc > , client : & Arc < ReportClient > ) -> anyhow:: Result < ( ) > {
76
73
if self . is_changed {
77
74
let result = if self . is_idle {
78
75
debug ! ( "Reporting as changed to idle" ) ;
0 commit comments