-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[PM-20210] Expand badge API #14801
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
base: main
Are you sure you want to change the base?
[PM-20210] Expand badge API #14801
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #14801 +/- ##
==========================================
+ Coverage 36.86% 36.91% +0.04%
==========================================
Files 3228 3237 +9
Lines 93388 93506 +118
Branches 14056 14064 +8
==========================================
+ Hits 34426 34515 +89
- Misses 57536 57565 +29
Partials 1426 1426 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
New Issues (3)Checkmarx found the following issues in this Pull Request
|
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.
👍 auth changes looks good, cool stuff goin on here
apps/browser/src/autofill/services/autofill-badge-updater.service.ts
Outdated
Show resolved
Hide resolved
apps/browser/src/autofill/services/autofill-badge-updater.service.ts
Outdated
Show resolved
Hide resolved
a26964a
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.
👍 Auth changes look good! Excited to see this work go in.
…ditional-update-options
The service assumes that the first emission from the state will be an empty one and discards it (techincally it just doesn't act on it because pairwise requires a minimum two emissions). This caused issues when a service is able to update the state before the observable got a change to properly initialize. To fix this we simply force an empty emission before anything else, that way we will always react to the emission from the state provider (because that would end up being the second emission). We then use distinctUntilChanged to avoid unecessarily acting on an empty state.
|
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.
Wow, the new implementation is nice 🏅 . LGTM!
BIT tests: |
BrowserApi.addListener(chrome.tabs.onReplaced, async (addedTabId, removedTabId) => { | ||
const newTab = await BrowserApi.getTab(addedTabId); | ||
if (!newTab) { | ||
this.logService.warning( | ||
`Tab replaced event received but new tab not found (id: ${addedTabId})`, | ||
); | ||
return; | ||
} | ||
|
||
this.tabReplaced$.next({ | ||
removedTabId, | ||
addedTab: newTab, | ||
}); | ||
}); | ||
BrowserApi.addListener(chrome.tabs.onUpdated, (_, changeInfo, tab) => { | ||
if (changeInfo.url) { | ||
this.tabUpdated$.next(tab); | ||
} | ||
}); | ||
BrowserApi.addListener(chrome.tabs.onRemoved, (tabId, _) => this.tabRemoved$.next(tabId)); | ||
} |
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.
hrm; is adding parallel listeners to the tab going to increase overhead/affect performance? Certainly cleaner code-wise, just wondering if we'd run into issues implementing this pattern for other tab event side-effects
🎟️ Tracking
📔 Objective
🆕 Updates
The previous implementation didn't handle tab ids which resulted in a bug where some separate windows which were actually interpreted as tabs by the browser caused the badge autofill number to disappear. An example of this is if you opened the Bitwarden popout:
The
BadgeService
now has full support for tabs meaning that you can now set tab-specific badge states. The autofill implementation has been completely rewritten to take advantage of this.In comparison to the old
badge-listener
the newBadgeService
does not need to be updated every time the user changes active tabs, instead the browser will keep track of all states for us and automatically change the badge whenever a different tab is displayed. This means that the newBadgeService
will not have to wake the service worker for active tab changes.📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes