File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ fn output_send(
162162) -> Result < ( ) , String > {
163163 let timestamp = timestamp
164164 . map ( |s| {
165- s. parse :: < u64 > ( )
165+ s. parse :: < u128 > ( )
166166 . map_err ( |e| format ! ( "Failed to parse timestamp: {e}" ) )
167167 } )
168168 . transpose ( ) ?;
@@ -178,15 +178,13 @@ fn output_send(
178178 drop ( state) ;
179179 let tstate = ( * tstate) . clone ( ) ;
180180 tauri:: async_runtime:: spawn ( async move {
181- let until = Instant :: now ( )
182- // We take `1ms` for processing overhead
183- + Duration :: from_millis ( timestamp - 1 )
184- . checked_sub (
185- SystemTime :: now ( )
186- . duration_since ( UNIX_EPOCH )
187- . expect ( "SystemTime is before epoch" ) ,
188- )
189- . unwrap_or ( Duration :: ZERO ) ;
181+ let current_epoch = SystemTime :: now ( )
182+ . duration_since ( UNIX_EPOCH )
183+ . expect ( "SystemTime is before epoch" )
184+ . as_millis ( ) ;
185+
186+ let delay_ms = timestamp. saturating_sub ( current_epoch) ;
187+ let until = Instant :: now ( ) + Duration :: from_millis ( delay_ms as u64 ) ;
190188 sleep_until ( until. into ( ) ) . await ;
191189
192190 let mut state = tstate. lock ( ) . unwrap_or_else ( PoisonError :: into_inner) ;
You can’t perform that action at this time.
0 commit comments