Rename followedInterestsState to followedInterestsUiState

pull/107/head
madroid 2 years ago
parent e0687e9aae
commit 63fd5a523b

@ -19,17 +19,17 @@ package com.google.samples.apps.nowinandroid.feature.foryou
/** /**
* A sealed hierarchy for the user's current followed interests state. * A sealed hierarchy for the user's current followed interests state.
*/ */
sealed interface FollowedInterestsState { sealed interface FollowedInterestsUiState {
/** /**
* The current state is unknown (hasn't loaded yet) * The current state is unknown (hasn't loaded yet)
*/ */
object Unknown : FollowedInterestsState object Unknown : FollowedInterestsUiState
/** /**
* The user hasn't followed any interests yet. * The user hasn't followed any interests yet.
*/ */
object None : FollowedInterestsState object None : FollowedInterestsUiState
/** /**
* The user has followed the given (non-empty) set of [topicIds] or [authorIds]. * The user has followed the given (non-empty) set of [topicIds] or [authorIds].
@ -37,5 +37,5 @@ sealed interface FollowedInterestsState {
data class FollowedInterests( data class FollowedInterests(
val topicIds: Set<String>, val topicIds: Set<String>,
val authorIds: Set<String> val authorIds: Set<String>
) : FollowedInterestsState ) : FollowedInterestsUiState
} }

@ -33,9 +33,9 @@ import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.model.data.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.model.data.SaveableNewsResource
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import com.google.samples.apps.nowinandroid.feature.foryou.FollowedInterestsState.FollowedInterests import com.google.samples.apps.nowinandroid.feature.foryou.FollowedInterestsUiState.FollowedInterests
import com.google.samples.apps.nowinandroid.feature.foryou.FollowedInterestsState.None import com.google.samples.apps.nowinandroid.feature.foryou.FollowedInterestsUiState.None
import com.google.samples.apps.nowinandroid.feature.foryou.FollowedInterestsState.Unknown import com.google.samples.apps.nowinandroid.feature.foryou.FollowedInterestsUiState.Unknown
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
@ -60,7 +60,7 @@ class ForYouViewModel @Inject constructor(
savedStateHandle: SavedStateHandle savedStateHandle: SavedStateHandle
) : ViewModel() { ) : ViewModel() {
private val followedInterestsState: StateFlow<FollowedInterestsState> = private val followedInterestsUiState: StateFlow<FollowedInterestsUiState> =
userDataRepository.userDataStream userDataRepository.userDataStream
.map { userData -> .map { userData ->
if (userData.followedAuthors.isEmpty() && userData.followedTopics.isEmpty()) { if (userData.followedAuthors.isEmpty() && userData.followedTopics.isEmpty()) {
@ -107,7 +107,7 @@ class ForYouViewModel @Inject constructor(
val feedState: StateFlow<NewsFeedUiState> = val feedState: StateFlow<NewsFeedUiState> =
combine( combine(
followedInterestsState, followedInterestsUiState,
snapshotFlow { inProgressTopicSelection }, snapshotFlow { inProgressTopicSelection },
snapshotFlow { inProgressAuthorSelection } snapshotFlow { inProgressAuthorSelection }
) { followedInterestsUserState, inProgressTopicSelection, inProgressAuthorSelection -> ) { followedInterestsUserState, inProgressTopicSelection, inProgressAuthorSelection ->
@ -148,7 +148,7 @@ class ForYouViewModel @Inject constructor(
val interestsSelectionState: StateFlow<ForYouInterestsSelectionUiState> = val interestsSelectionState: StateFlow<ForYouInterestsSelectionUiState> =
combine( combine(
followedInterestsState, followedInterestsUiState,
topicsRepository.getTopicsStream(), topicsRepository.getTopicsStream(),
authorsRepository.getAuthorsStream(), authorsRepository.getAuthorsStream(),
snapshotFlow { inProgressTopicSelection }, snapshotFlow { inProgressTopicSelection },

Loading…
Cancel
Save