Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Fix #192: Resend product data after a delay to reset toolbar icon. #220

Merged
merged 2 commits into from
Oct 30, 2018

Conversation

Osmose
Copy link
Contributor

@Osmose Osmose commented Oct 28, 2018

Forgive me father for I have sinned

In my defense, this is much more reliable than any other way I could find of detecting this error. There's still a possibility of very long page loads causing the toolbar icon to be reset after the timers go off, but that's just life. And 64 and above aren't affected by this bug anyway, so it's a temporary pain.

Also I noticed an error being logged to the console a bunch while trying to fix this and included a fix for that too.

@Osmose Osmose requested a review from mythmon October 28, 2018 17:27
Copy link
Contributor

@mythmon mythmon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was the second time I've reviewed something for #192, I went and actually read the bug. It didn't really make sense until I looked at the patch in bug 1493470 (specifically the commit message), and realized this applied both to both page actions and browser actions. This makes more sense now.

If this weren't already being fixed in Firefox 64, I'd push for a better thing than just trying twice and praying, but I think this is fine since it is a temporary workaraound.

@Osmose Osmose force-pushed the toolbar-cleared-again branch from 4526a15 to 75c6c17 Compare October 30, 2018 00:20
@Osmose Osmose merged commit 0190c72 into mozilla:master Oct 30, 2018
@Osmose Osmose deleted the toolbar-cleared-again branch October 30, 2018 00:22
biancadanforth added a commit to biancadanforth/price-tracker that referenced this pull request Nov 2, 2018
* Note: This fix is complicated by the fact that a 'price alert' badge only changes the global badge state. An 'add' product badge changes the tab-specific badge state, which takes precedence over the global badge state.

To avoid event duplication for 'badge_toolbar_button':
  * Add 'hasBadgeTextChanged' function with optional 'tabId' argument, so that the event only fires if the badge text has changed.
    * Previously, we were getting a bunch of redundant `badge_toolbar_button` events for ‘price_alert’ any time the state was changed and we’re on a page with an ‘add’ badge. Since `handlePriceAlerts` is called every time state changes in any way (`store.subscribe(handlePriceAlerts)`), we now check to see if the badge text has changed for a price alert badge on the global browserAction button before recording the 'badge_toolbar_button' with badge type 'price_alert' event.
    * Previously, if tab 1 had badge type 'add' and tab 2 had badge type 'price_alert', and I switch to tab 2 before any calls to 'resend' (mozilla#220) are made from tab 1, I would get two extra 'badge_toolbar_button' of type 'add' events. Adding the 'tabId' optional argument fixes this bug.
biancadanforth added a commit to biancadanforth/price-tracker that referenced this pull request Nov 6, 2018
* Note: This fix is complicated by the fact that a 'price alert' badge only changes the global badge state. An 'add' product badge changes the tab-specific badge state, which takes precedence over the global badge state.

To avoid event duplication for 'badge_toolbar_button':
  * Add 'hasBadgeTextChanged' function with optional 'tabId' argument, so that the event only fires if the badge text has changed.
    * Previously, we were getting a bunch of redundant `badge_toolbar_button` events for ‘price_alert’ any time the state was changed and we’re on a page with an ‘add’ badge. Since `handlePriceAlerts` is called every time state changes in any way (`store.subscribe(handlePriceAlerts)`), we now check to see if the badge text has changed for a price alert badge on the global browserAction button before recording the 'badge_toolbar_button' with badge type 'price_alert' event.
    * Previously, if tab 1 had badge type 'add' and tab 2 had badge type 'price_alert', and I switch to tab 2 before any calls to 'resend' (mozilla#220) are made from tab 1, I would get two extra 'badge_toolbar_button' of type 'add' events. Adding the 'tabId' optional argument fixes this bug.
biancadanforth added a commit to biancadanforth/price-tracker that referenced this pull request Nov 6, 2018
* Note: This fix is complicated by the fact that a 'price alert' badge only changes the global badge state. An 'add' product badge changes the tab-specific badge state, which takes precedence over the global badge state.

To avoid event duplication for 'badge_toolbar_button':
  * Add 'hasBadgeTextChanged' function with optional 'tabId' argument, so that the event only fires if the badge text has changed.
    * Previously, we were getting a bunch of redundant `badge_toolbar_button` events for ‘price_alert’ any time the state was changed and we’re on a page with an ‘add’ badge. Since `handlePriceAlerts` is called every time state changes in any way (`store.subscribe(handlePriceAlerts)`), we now check to see if the badge text has changed for a price alert badge on the global browserAction button before recording the 'badge_toolbar_button' with badge type 'price_alert' event.
    * Previously, if tab 1 had badge type 'add' and tab 2 had badge type 'price_alert', and I switch to tab 2 before any calls to 'resend' (mozilla#220) are made from tab 1, I would get two extra 'badge_toolbar_button' of type 'add' events. Adding the 'tabId' optional argument fixes this bug.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants