SupremeTechnopriest / react-idle-timer

User activity timer component
https://idletimer.dev
MIT License
1.15k stars 143 forks source link

Reset function is not re-starting getTotalActiveTime #301

Closed tamirble closed 1 year ago

tamirble commented 2 years ago

Bug information

Affected Module

Describe the bug

Calling the reset function sometimes leave the getTotalActiveTime value on 0 without any movement

To Reproduce

Steps to reproduce the behavior: I've prepared the following sandbox for it: https://codesandbox.io/s/idle-timer-forked-3rggu9

  1. Waiting the idle timeout (3 seconds on my example) and clicking on Reset a few times, is creating a situation where the getTotalActiveTime stays on 0 although it should start running.

Expected behavior

I would expect the getTotalActiveTime function to start counting according to its name

Screenshots

If applicable, add screenshots to help explain your problem.

image

System Information (please complete the following information)

Additional context

You can also see a video of the problem here: https://streamable.com/a2xw4i

SupremeTechnopriest commented 1 year ago

I have added getIdleTime and getActiveTime that will be reset when reset is called. The getTotal* methods will keep track for the entire life of the component. This will be in the next release. If you want to test it out, you can install the latest release candidate with npm i react-idle-timer@next.