From 96167e1300563bede50d53751ebdfe7cd2a7429d Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Mon, 30 Dec 2024 19:29:24 +0000 Subject: [SB][Notif] Reduce log spam by adding `distinctUntilChanged`. Fixes: 386355190 Bug: 364653005 Flag: com.android.systemui.status_bar_notification_chips Test: Get multiple non-promoted notifs, then `adb shell dumpsys activity service com.android.systemui/.SystemUIService StatusBarChips` -> verify no extra log lines Change-Id: I5733dc7b334b807b5ab5074fde45acde6149ca6d --- .../chips/notification/ui/viewmodel/NotifChipsViewModel.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt index bcd8cfaa5c5a..2f6431b05c8b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt @@ -33,6 +33,7 @@ import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.launch /** A view model for status bar chips for promoted ongoing notifications. */ @@ -50,11 +51,12 @@ constructor( */ val chips: Flow> = combine( - notifChipsInteractor.notificationChips, - headsUpNotificationInteractor.statusBarHeadsUpState, - ) { notifications, headsUpState -> - notifications.map { it.toActivityChipModel(headsUpState) } - } + notifChipsInteractor.notificationChips, + headsUpNotificationInteractor.statusBarHeadsUpState, + ) { notifications, headsUpState -> + notifications.map { it.toActivityChipModel(headsUpState) } + } + .distinctUntilChanged() /** Converts the notification to the [OngoingActivityChipModel] object. */ private fun NotificationChipModel.toActivityChipModel( -- cgit v1.2.3-59-g8ed1b