Skip to content

Commit 2d679c4

Browse files
committed
feat: implemented notification badge in the Hub Menu tab
1 parent 424cf9e commit 2d679c4

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

WooCommerce/Classes/ViewRelated/MainTabBarController.swift

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ final class MainTabBarController: UITabBarController {
123123
configureTabViewControllers()
124124
observeSiteIDForViewControllers()
125125

126-
loadReviewsTabNotificationCountAndUpdateBadge()
126+
loadHubMenuTabNotificationCountAndUpdateBadge()
127127
}
128128

129129
override func viewWillAppear(_ animated: Bool) {
@@ -133,7 +133,7 @@ final class MainTabBarController: UITabBarController {
133133
/// We hook up KVO in this spot... because at the point in which `viewDidLoad` fires, we haven't really fully
134134
/// loaded the childViewControllers, and the tabBar isn't fully initialized.
135135
///
136-
startListeningToReviewsTabBadgeUpdates()
136+
startListeningToHubMenuTabBadgeUpdates()
137137
startListeningToOrdersBadge()
138138
}
139139

@@ -467,38 +467,37 @@ private extension MainTabBarController {
467467
}
468468
}
469469

470-
// MARK: - Reviews Tab Badge Updates
470+
// MARK: - Hub Menu Tab Badge Updates
471471
//
472472
private extension MainTabBarController {
473473

474474
/// Setup: KVO Hooks.
475475
///
476-
func startListeningToReviewsTabBadgeUpdates() {
476+
func startListeningToHubMenuTabBadgeUpdates() {
477477
NotificationCenter.default.addObserver(self,
478-
selector: #selector(loadReviewsTabNotificationCountAndUpdateBadge),
478+
selector: #selector(loadHubMenuTabNotificationCountAndUpdateBadge),
479479
name: .reviewsBadgeReloadRequired,
480480
object: nil)
481481
}
482482

483-
@objc func loadReviewsTabNotificationCountAndUpdateBadge() {
483+
@objc func loadHubMenuTabNotificationCountAndUpdateBadge() {
484484
guard let siteID = stores.sessionManager.defaultStoreID else {
485485
return
486486
}
487487

488488
let action = NotificationCountAction.load(siteID: siteID, type: .kind(.comment)) { [weak self] count in
489-
self?.updateReviewsTabBadge(count: count)
489+
self?.updateHubMenuTabBadge(count: count)
490490
}
491491
stores.dispatch(action)
492492
}
493493

494-
/// Displays or Hides the Dot on the Reviews tab, depending on the notification count
494+
/// Displays or Hides the Dot on the Hub Menu tab, depending on the notification count
495495
///
496-
func updateReviewsTabBadge(count: Int) {
497-
//TODO-5509: handle reviews badge
498-
guard !isHubMenuFeatureFlagOn else {
496+
func updateHubMenuTabBadge(count: Int) {
497+
guard isHubMenuFeatureFlagOn else {
499498
return
500499
}
501-
let tab = WooTab.reviews
500+
let tab = WooTab.hubMenu
502501
let tabIndex = tab.visibleIndex(isHubMenuFeatureFlagOn)
503502
notificationsBadge.badgeCountWasUpdated(newValue: count, tab: tab, in: tabBar, tabIndex: tabIndex)
504503
}

0 commit comments

Comments
 (0)