@@ -32,25 +32,29 @@ function checkHours(soft){
3232 //logJ(record.getRegex());
3333 //logJ("Pre:");
3434 //logJ(record.getCurrentDuration(), record.getNormalBreak() * 1000);
35-
36- if ( record . getCurrentDuration ( ) < record . getNormalBreak ( ) * 1000 &&
35+
36+ let sinceLastCheck = Math . min ( nowDate . getTime ( ) - record . getLastCheck ( ) . getTime ( ) ,
37+ interval ) ;
38+
39+ if ( record . getCurrentDuration ( ) + sinceLastCheck < record . getNormalBreak ( ) * 1000 &&
3740 nowDate . getTime ( ) > record . getLastCheck ( ) . getTime ( ) &&
3841 nowDate . getTime ( ) < record . getLastCheck ( ) . getTime ( )
3942 + record . getNormalTimeout ( ) * 1000 ) {
4043 // If timeout didn't pass since last visit
4144 // and currentStreak is less than allowed time,
4245 // increment current streak
4346 updatedElements [ ii ] = record . withCurrentDuration (
44- record . getCurrentDuration ( )
45- + Math . min ( nowDate . getTime ( ) - record . getLastCheck ( ) . getTime ( ) ,
46- interval ) )
47- . withLastCheck ( nowDate ) ;
47+ record . getCurrentDuration ( ) + sinceLastCheck )
48+ . withLastCheck ( nowDate ) ;
49+
4850 } else if ( nowDate . getTime ( )
4951 >= record . getLastCheck ( ) . getTime ( ) + record . getNormalTimeout ( ) * 1000 ) {
5052 // If timeout did pass since last visit
5153 // reset current streak
5254 updatedElements [ ii ] = record . withCurrentDuration ( 0 ) . withLastCheck ( nowDate ) ;
53- } else if ( record . getCurrentDuration ( ) >= record . getNormalBreak ( ) * 1000 ) {
55+
56+ } else if ( record . getCurrentDuration ( ) + sinceLastCheck
57+ >= record . getNormalBreak ( ) * 1000 ) {
5458 // Otherwise if current streak is more or equal to allowed time, deny entry
5559 return true ;
5660 }
0 commit comments