salarcode / SmartProxy

Firefox/Chrome browser extension. SmartProxy will automatically enable/disable proxy for the sites you visit, based on customizable patterns.
https://addons.mozilla.org/en-US/firefox/addon/smartproxy/
GNU General Public License v3.0
1.93k stars 117 forks source link

fix: subscription refresh not happening sometimes #395

Closed WofWca closed 1 month ago

WofWca commented 2 months ago

Since the background scripts in MV3 are non-persistent, they might shut down often, losing all setInterval timers.

If the background script doesn't live longer that refresh period, then it will never refresh.

This commit checks lastTryDate and does setTimeout based on that. If the list has not been refreshed for longer than refreshRate, we'll refresh it immediately.

FYI however there is another bug: if a fetch fails, lastTryDate does not get stored in local storage, so a refresh attempt will happen immediately as the background script starts. This is not a big problem.

salarcode commented 1 month ago

Thanks a lot!

lastTryDate do not hold valid date format so the code wouldn't work without my commit.

Will do some updates on this but very good thanks.

salarcode commented 1 month ago

Also lastTryDate always gets updated, I've pushed a commit with slight adjustment to the logic which should fix the mentioned issue