Bug 1858909 Comment 2 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Concerning Bug 1851246, one change to the settings component was the [condition to render the ads toggle](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/content/settings.mjs#56). Previously, we relied on a `RPMGetBoolPref` call to read the ad feature pref. But now we just read the pref value passed from `shopping-container`. Therefore it seems that the property `adsEnabled` is falsey when passed to the settings component in this case. We read the pref in the container [here](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/content/shopping-container.mjs#104) from two places in the sidebar child actor:
- clearing analysis details on the sidebar for a "non polled request" ([searchfox](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/ShoppingSidebarChild.sys.mjs#200)), so something like refreshing the page and changing opt-in/opt-out state.
- after successfully fetching analysis details ([searchfox](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/ShoppingSidebarChild.sys.mjs#271)). Ex. requesting a re-analysis

I suspect the cause of the issue to be:
- In the case where an analysis is in progress, when we detect a "non polled request" (like refreshing the page, changing opt-in/opt-out state), we update the sidebar to show the in progress message via [this call](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/ShoppingSidebarChild.sys.mjs#249).
- In doing so, we end up overwriting some data we had, such as `adsEnabled` and will cause it to be undefined once read in `shopping-container in the `_update` function.

Another note:
This does not seem to be limited to opt-in and then opt-out. It occurs as well if you:
1. request re-analysis (stale analysis)
2. duplicate tab or refresh current page with analysis running
3. view settings; the toggle will still not be there
Concerning Bug 1851246, one change to the settings component was the [condition to render the ads toggle](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/content/settings.mjs#56). Previously, we relied on a `RPMGetBoolPref` call to read the ad feature pref. But now we just read the pref value passed from `shopping-container`. Therefore it seems that the property `adsEnabled` is falsey when passed to the settings component in this case. We read the pref in the container [here](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/content/shopping-container.mjs#104) from two places in the sidebar child actor:
- clearing analysis details on the sidebar for a "non polled request" ([searchfox](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/ShoppingSidebarChild.sys.mjs#200)), so something like refreshing the page and changing opt-in/opt-out state.
- after successfully fetching analysis details ([searchfox](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/ShoppingSidebarChild.sys.mjs#271)). Ex. requesting a re-analysis

I suspect the cause of the issue to be:
- In the case where an analysis is in progress, when we detect a "non polled request" (like refreshing the page, changing opt-in/opt-out state), we update the sidebar to show the in progress message via [this call](https://searchfox.org/mozilla-central/rev/6e5b9a5a1edab13a1b2e2e90944b6e06b4d8149c/browser/components/shopping/ShoppingSidebarChild.sys.mjs#249).
- In doing so, we end up overwriting some data we had, such as `adsEnabled` and will cause it to be undefined once read in `shopping-container` in the `_update` function.

Another note:
This does not seem to be limited to opt-in and then opt-out. It occurs as well if you:
1. request re-analysis (stale analysis)
2. duplicate tab or refresh current page with analysis running
3. view settings; the toggle will still not be there

Back to Bug 1858909 Comment 2