raicem / impulse-blocker

Block distracting websites when you are browsing the web. Use for procrastination.
https://blog.cemunalan.com.tr/2017/05/17/impulse-blocker-guide/
MIT License
169 stars 25 forks source link

Pause timer bug upon starting browser #70

Open b1100111 opened 3 years ago

b1100111 commented 3 years ago

This worked properly in the last release so has newly broken in v1.2.0. It might be related to "dark mode" since I have that turned on and now see the IB screen in dark when seeing this error.

I am not 100% sure how to reproduce but it seems that when I sometimes return to Firefox and go to a site that is blocked by IB, I then go to the menu to pause it but it already shows as paused and always for slightly less than 60 minutes. I have to cancel pause (even though it is not really paused) and then start a pause again to see might site. The 60 minutes is noteworthy because I never pause more than 5 or 15 minutes. So, it is some default value that it is getting elsewhere.

b1100111 commented 3 years ago

This is on Windows x86.

pedro-w commented 3 years ago

I also have seen this, but I am using Firefox on Mac and I don't use dark mode. So it is not specific to Windows or dark mode.

pedro-w commented 3 years ago

I can't reproduce it 100% reliably either but it seems to happen if I pause, close FF during the pause period and then re-open it after the pause would have elapsed. As far as I can see it is actually blocking normally, just the UI shows a pause timer. This timer just runs from 60 minutes to zero and rolls around to 60 minutes again. image

Is it somethng to do with the way it restores its state in function boot()? https://github.com/raicem/impulse-blocker/blob/5e7a8413c5f2aacf57f4289f8d4970eca49e98eb/src/ImpulseBlocker.js#L33-L50

pedro-w commented 3 years ago

The rolling one hour timer is, I believe, just because of this code: https://github.com/raicem/impulse-blocker/blob/5e7a8413c5f2aacf57f4289f8d4970eca49e98eb/src/popup/components/Pause/PauseSection.js#L79-L91 Somehow this.state.secondsToExpire gets set to a negative value and what we see is just that time truncated by the 'mm:ss' format. So I suspect the root cause is finding out how secondsToExpire becomes negative.