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

Commit c7865c30 authored by Hawkwood Glazier's avatar Hawkwood Glazier Committed by Android Build Coastguard Worker
Browse files

Select the default clock if current clock id was not found

Bug: 295371293
Test: Manually tested invalid clock ids
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e71e4fc1634df44e14471e1cd2b3515b44c3aa3a)
Merged-In: Iff766fdb9ef5c914eda5454686d8181562748dec
Change-Id: Iff766fdb9ef5c914eda5454686d8181562748dec
parent 087efa48
Loading
Loading
Loading
Loading
+5 −7
Original line number Diff line number Diff line
@@ -52,11 +52,9 @@ class ClockPickerRepositoryImpl(
    override val allClocks: Flow<List<ClockMetadataModel>> =
        callbackFlow {
                fun send() {
                    val allClocks =
                        registry
                            .getClocks()
                            .filter { "NOT_IN_USE" !in it.clockId }
                            .map { it.toModel() }
                    val activeClockId = registry.activeClockId
                    val allClocks = registry.getClocks().map { it.toModel() }

                    trySend(allClocks)
                }

@@ -83,12 +81,12 @@ class ClockPickerRepositoryImpl(
    override val selectedClock: Flow<ClockMetadataModel> =
        callbackFlow {
                fun send() {
                    val currentClockId = registry.currentClockId
                    val activeClockId = registry.activeClockId
                    val metadata = registry.settings?.metadata
                    val model =
                        registry
                            .getClocks()
                            .find { clockMetadata -> clockMetadata.clockId == currentClockId }
                            .find { clockMetadata -> clockMetadata.clockId == activeClockId }
                            ?.toModel(
                                selectedColorId = metadata?.getSelectedColorId(),
                                colorTone = metadata?.getColorTone()