mohamedmansour / prayer-times-extension

Under Development: Prayer Time Calculation based on Geolocation for Chromium and Firefox
https://chrome.google.com/webstore/detail/ndmbeogingkjkmmkoomnigifmpajmbkc
64 stars 23 forks source link

Watch system time changes #22

Closed mohamedmansour closed 6 years ago

mohamedmansour commented 6 years ago

I recall from old times that Prayer Times didn't respond to system time changes: For instance, when a user changes the system time, Prayer Times continued to use the old time until the browser is restarted. Other examples include when the system time changed due to observing daylight saving, or when the computer came back from the sleep/hibernate while the browser was open.

via @msdousti

mohamedmansour commented 6 years ago

This is going to be an interesting one. Perhaps we need to introduce a health state timer. More research is needed

msdousti commented 6 years ago

I believe I found the culprit. Check out these lines:

https://github.com/mohamedmansour/prayer-times-extension/blob/92aaa8c862cef758d2998402ac9f58e38ea4a7c0/js/popup_controller.js#L67-L76

I tried this in Chrome DevTools (on Windows 10):

(new Date()).toLocaleTimeString()

It showed current time. Then I changed the system time, and executed the above line again in Chrome DevTools. It didn't change immediately, though after 30 seconds, Chrome caught up with the system time.

I tried the same thing under Firefox, which immediately reflected system time changes.

This might be a Chrome issue, or it might be there by design. A little research shows a similar issue was reported back in 2010:

https://bugs.chromium.org/p/chromium/issues/detail?id=43293

mohamedmansour commented 6 years ago

I found a major bug where the prayer badge time wasn't updating, I fixed it in here: cbd0cbe68dfdbe092ba039a54bbcdb41308f64d8

The time should always update in AlarmClock, there is another issue I noticed, trying to understand why he included nonPrayerTimesNames in AlarmClock I didn't implement that part, brother @alir1982 contributed that code 8 years ago :)

mohamedmansour commented 6 years ago

I believe this works!