@@ -84,7 +84,7 @@ import { TRIGGER_TYPES } from './controllers/metamask-notifications/constants/no
84
84
const BADGE_COLOR_APPROVAL = '#0376C9' ;
85
85
// eslint-disable-next-line @metamask/design-tokens/color-no-hex
86
86
const BADGE_COLOR_NOTIFICATION = '#D73847' ;
87
- const BADGE_MAX_NOTIFICATION_COUNT = 9 ;
87
+ const BADGE_MAX_COUNT = 9 ;
88
88
89
89
// Setup global hook for improved Sentry state snapshots during initialization
90
90
const inTest = process . env . IN_TEST ;
@@ -975,6 +975,17 @@ export function setupController(
975
975
976
976
controller . txController . initApprovals ( ) ;
977
977
978
+ /**
979
+ * Formats a count for display as a badge label.
980
+ *
981
+ * @param {number } count - The count to be formatted.
982
+ * @param {number } maxCount - The maximum count to display before using the '+' suffix.
983
+ * @returns {string } The formatted badge label.
984
+ */
985
+ function getBadgeLabel ( count , maxCount ) {
986
+ return count > maxCount ? `${ maxCount } +` : String ( count ) ;
987
+ }
988
+
978
989
/**
979
990
* Updates the Web Extension's "badge" number, on the little fox in the toolbar.
980
991
* The number reflects the current number of pending transactions or message signatures needing user approval.
@@ -987,12 +998,9 @@ export function setupController(
987
998
let badgeColor = BADGE_COLOR_APPROVAL ;
988
999
989
1000
if ( pendingApprovalCount ) {
990
- label = String ( pendingApprovalCount ) ;
1001
+ label = getBadgeLabel ( pendingApprovalCount , BADGE_MAX_COUNT ) ;
991
1002
} else if ( unreadNotificationsCount > 0 ) {
992
- label =
993
- unreadNotificationsCount > BADGE_MAX_NOTIFICATION_COUNT
994
- ? `${ BADGE_MAX_NOTIFICATION_COUNT } +`
995
- : String ( unreadNotificationsCount ) ;
1003
+ label = getBadgeLabel ( unreadNotificationsCount , BADGE_MAX_COUNT ) ;
996
1004
badgeColor = BADGE_COLOR_NOTIFICATION ;
997
1005
}
998
1006
0 commit comments