|
|
@ -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 },
|
|
|
|