-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sync): move options sync to background process #2062
base: main
Are you sure you want to change the base?
Conversation
@AdamGhst, I did my testing between Firefox and Chrome, but please do a round of smokes related to the sync process. |
Builds for commit 822ccda: |
@@ -36,6 +36,9 @@ store | |||
}; | |||
} | |||
|
|||
// Sync options with background | |||
chrome.runtime.sendMessage({ action: 'syncOptions' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we await here? we don't want UI to flicker in case option change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already discussed awaiting the sync process in another context, and our decision was to not wait for it. It can be long or failing for many reasons (bad internet connection etc) - The settings page are available immediately for the user (they are local).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting Sync stops working.
Steps to reproduce:
- Login to Ghostery Account both browsers. Setting Sync is ON on both.
- Chrome - FF Setting sync works great.
- Turn off the sync option in Chrome and leave it enabled in FF.
- I make changes to the Ghostery settings in Chrome. No reaction in FF. As expected.
- Turn the sync option back on in Chrome.
- Make changes to the Ghostery settings in Chrome.
- Syncing stops working. No changes in FF after reloading the Ghostery settings page.
The same happens other way around. (FF - Chrome)
This PR moves out the sync of options into the background process.
The trigger of the sync process programmatically stays as it was - every time the background starts up the sync is triggered. However, if any other context wants to force the sync, the message
syncOptions
must be sent (added to the settings page and panel).The
background/session.js
can be cleaned up from alarms. As the sync is triggered with every background process start-up, the alarms don't give much, as any request made by the browser brings the BG back to life. For the same reason, it is safe to trigger sync then, as from my testing, BG is not killed that often (many sites make some background calls, or the user moves the mouse over the page or something similar).Also, the sync option in the Account section is unlocked. I found a use case, where you can log in, switch sync to false, and then log out, keeping the sync set to
false
. On the other hand, currently, it is impossible to log in without sync turned off. It is pointless to block this setting before the user is logged in, as it might be "hacked" anyway.After code review, the PR requires manual testing.