Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fecb36ff authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Filter irrelevant volume changes" into main

parents fff378c1 1024fe20
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -41,11 +41,13 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.stateIn

/*
@@ -129,9 +131,10 @@ constructor(

    init {
        userVolumeUpdates
            .filterNotNull()
            .mapNotNull { it?.newVolumeLevel?.roundToInt() }
            .distinctUntilChanged()
            .mapLatest { volume ->
                interactor.setStreamVolume(volume.newVolumeLevel.roundToInt())
                interactor.setStreamVolume(volume)
                Events.writeEvent(Events.EVENT_TOUCH_LEVEL_CHANGED, model.first().stream, volume)
            }
            .launchIn(coroutineScope)