@@ -378,7 +378,29 @@ <h3>
378378 call ( "floating" ) ;
379379 hasFloating = true ;
380380
381- //repeat so always able to be sent
381+ // Send immediate heartbeat first to prevent freeze at zero
382+ if ( methodFromStart !== 3 ) {
383+ let remainingMs = ( ( method === 1 ) ? workTime : restTime ) - new Date ( ) . getTime ( ) + startTime -
384+ ( times === 0 ? firstTimeDiscount : 0 ) ;
385+ if ( remainingMs < 0 ) remainingMs = 0 ;
386+ ipc . send ( "floating-heartbeat" , {
387+ remainingSeconds : Math . floor ( remainingMs / 1000 ) ,
388+ totalMs : ( method === 1 ) ? workTime : restTime ,
389+ method : method ,
390+ isWorking : isClockWorking ,
391+ isOnlyRest : isOnlyRest
392+ } ) ;
393+ } else {
394+ ipc . send ( "floating-heartbeat" , {
395+ remainingSeconds : seconds ,
396+ totalMs : 0 ,
397+ method : 3 ,
398+ isWorking : isClockWorking ,
399+ isOnlyRest : isOnlyRest
400+ } ) ;
401+ }
402+
403+ // Repeat so always able to be sent (backup heartbeats)
382404 if ( methodFromStart !== 3 )
383405 for ( let floatingRepeater = 1 ; floatingRepeater < 5 ; floatingRepeater ++ )
384406 setTimeout ( function ( ) {
@@ -1247,6 +1269,19 @@ <h3>
12471269 $ ( "#skipper-container" ) . css ( "display" , "inline" ) ;
12481270 }
12491271 }
1272+ // Send immediate heartbeat after state change to prevent freeze at zero
1273+ if ( hasFloating && times !== loop * 2 ) {
1274+ let remainingMs = ( ( method === 1 ) ? workTime : restTime ) - new Date ( ) . getTime ( ) + startTime -
1275+ ( times === 0 ? firstTimeDiscount : 0 ) ;
1276+ if ( remainingMs < 0 ) remainingMs = 0 ;
1277+ ipc . send ( "floating-heartbeat" , {
1278+ remainingSeconds : Math . floor ( remainingMs / 1000 ) ,
1279+ totalMs : ( method === 1 ) ? workTime : restTime ,
1280+ method : methodFromStart === 3 ? 3 : method ,
1281+ isWorking : isClockWorking ,
1282+ isOnlyRest : isOnlyRest
1283+ } ) ;
1284+ }
12501285 } else {
12511286 stopper ( ) ;
12521287 setTimeout ( function ( ) {
@@ -1273,6 +1308,19 @@ <h3>
12731308 $ ( "#skipper-container" ) . css ( "display" , "inline" ) ;
12741309 }
12751310 }
1311+ // Send immediate heartbeat after state change to prevent freeze at zero
1312+ if ( hasFloating && times !== loop * 2 ) {
1313+ let remainingMs = ( ( method === 1 ) ? workTime : restTime ) - new Date ( ) . getTime ( ) + startTime -
1314+ ( times === 0 ? firstTimeDiscount : 0 ) ;
1315+ if ( remainingMs < 0 ) remainingMs = 0 ;
1316+ ipc . send ( "floating-heartbeat" , {
1317+ remainingSeconds : Math . floor ( remainingMs / 1000 ) ,
1318+ totalMs : ( method === 1 ) ? workTime : restTime ,
1319+ method : methodFromStart === 3 ? 3 : method ,
1320+ isWorking : isClockWorking ,
1321+ isOnlyRest : isOnlyRest
1322+ } ) ;
1323+ }
12761324 } , 250 ) ;
12771325 }
12781326 }
0 commit comments