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