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

Commit 1d5b8703 authored by shirleyqian's avatar shirleyqian
Browse files

Set the default value of firstTimeEducationShownAt when shared preference is null.

Sometimes the shared pref can be null and the previous default value of firstTimeEducationShownAt is null. Thus the edu tooltip will be displayed and quickly disappear after the shared pref is loaded.

Bug: 427866158
Test: local
Flag: com.android.systemui.enable_underlay
Change-Id: Ica8f38aac8886ecc699b9844b2f90668719481d6
parent 845a67a2
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -113,7 +113,9 @@ constructor(
    private val firstTimeEducationShownAt: Flow<Long?> =
        sharedPreferences
            .flatMapLatestConflated { prefs ->
                prefs?.observeLong(KEY_FIRST_TIME_ONBOARDING_SHOWN_AT, -1L) ?: flowOf(null)
                // If the shared preference is not initialized, set the default value to 0L to avoid
                // showing the first time education.
                prefs?.observeLong(KEY_FIRST_TIME_ONBOARDING_SHOWN_AT, -1L) ?: flowOf(0L)
            }
            .map { if (it == -1L) null else it }
            .distinctUntilChanged()