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

Commit 17468b05 authored by George Lin's avatar George Lin
Browse files

Avoid duplicate down stream emits

Making the shared flow Eagerly to avoid a second down stream flow emit
from subcribing to the upstream flow (the first time is from the cached
replay value)

Test: Manually log that there's only one emit when returning to the main
      screen from the clock settings screen
Bug: 289288356
Change-Id: Icf815f19a95e264d1141ec0f6e1d078aec8eb147
parent b9bc4760
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
@@ -146,9 +147,10 @@ class ClockPickerRepositoryImpl(
            )
            .map { setting -> setting == 1 }
            .map { isDynamic -> if (isDynamic) ClockSize.DYNAMIC else ClockSize.SMALL }
            .distinctUntilChanged()
            .shareIn(
                scope = scope,
                started = SharingStarted.WhileSubscribed(),
                started = SharingStarted.Eagerly,
                replay = 1,
            )