Skip to content

Commit b043d8d

Browse files
committed
Replace workaround on SettingsViewModel now that a fix has been deployed
The issue has been addressed in `androidx.compose.ui:ui:1.5.0`.
1 parent a5c030f commit b043d8d

File tree

1 file changed

+3
-8
lines changed
  • feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings

1 file changed

+3
-8
lines changed

feature/settings/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/settings/SettingsViewModel.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import com.google.samples.apps.nowinandroid.core.model.data.ThemeBrand
2424
import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Loading
2525
import com.google.samples.apps.nowinandroid.feature.settings.SettingsUiState.Success
2626
import dagger.hilt.android.lifecycle.HiltViewModel
27-
import kotlinx.coroutines.flow.SharingStarted
27+
import kotlinx.coroutines.flow.SharingStarted.Companion.WhileSubscribed
2828
import kotlinx.coroutines.flow.StateFlow
2929
import kotlinx.coroutines.flow.map
3030
import kotlinx.coroutines.flow.stateIn
3131
import kotlinx.coroutines.launch
3232
import javax.inject.Inject
33+
import kotlin.time.Duration.Companion.seconds
3334

3435
@HiltViewModel
3536
class SettingsViewModel @Inject constructor(
@@ -48,13 +49,7 @@ class SettingsViewModel @Inject constructor(
4849
}
4950
.stateIn(
5051
scope = viewModelScope,
51-
// Starting eagerly means the user data is ready when the SettingsDialog is laid out
52-
// for the first time. Without this, due to b/221643630 the layout is done using the
53-
// "Loading" text, then replaced with the user editable fields once loaded, however,
54-
// the layout height doesn't change meaning all the fields are squashed into a small
55-
// scrollable column.
56-
// TODO: Change to SharingStarted.WhileSubscribed(5_000) when b/221643630 is fixed
57-
started = SharingStarted.Eagerly,
52+
started = WhileSubscribed(5.seconds.inWholeMilliseconds),
5853
initialValue = Loading,
5954
)
6055

0 commit comments

Comments
 (0)