Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smalluban
Copy link
Collaborator

@smalluban smalluban commented Nov 14, 2024

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.

@smalluban
Copy link
Collaborator Author

@AdamGhst, I did my testing between Firefox and Chrome, but please do a round of smokes related to the sync process.

@AdamGhst AdamGhst added the package CI: create extension packages label Nov 15, 2024
Copy link

@@ -36,6 +36,9 @@ store
};
}

// Sync options with background
chrome.runtime.sendMessage({ action: 'syncOptions' });
Copy link
Member

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

Copy link
Collaborator Author

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).

Copy link

@AdamGhst AdamGhst left a 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:

  1. Login to Ghostery Account both browsers. Setting Sync is ON on both.
  2. Chrome - FF Setting sync works great.
  3. Turn off the sync option in Chrome and leave it enabled in FF.
  4. I make changes to the Ghostery settings in Chrome. No reaction in FF. As expected.
  5. Turn the sync option back on in Chrome.
  6. Make changes to the Ghostery settings in Chrome.
  7. Syncing stops working. No changes in FF after reloading the Ghostery settings page.

The same happens other way around. (FF - Chrome)

@smalluban smalluban removed the package CI: create extension packages label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants