Renamed SaveableNewsResource to UserNewsResource

pull/507/head
magicalmeghan 2 years ago committed by Don Turner
parent e82a3d9621
commit 6941e2082b

@ -18,7 +18,7 @@ package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository import com.google.samples.apps.nowinandroid.core.data.repository.NewsRepository
import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
@ -47,7 +47,7 @@ class GetSaveableNewsResourcesUseCase @Inject constructor(
*/ */
operator fun invoke( operator fun invoke(
filterTopicIds: Set<String> = emptySet() filterTopicIds: Set<String> = emptySet()
): Flow<List<SaveableNewsResource>> = ): Flow<List<UserNewsResource>> =
if (filterTopicIds.isEmpty()) { if (filterTopicIds.isEmpty()) {
newsRepository.getNewsResources() newsRepository.getNewsResources()
} else { } else {
@ -57,11 +57,11 @@ class GetSaveableNewsResourcesUseCase @Inject constructor(
private fun Flow<List<NewsResource>>.mapToSaveableNewsResources( private fun Flow<List<NewsResource>>.mapToSaveableNewsResources(
savedNewsResourceIds: Flow<Set<String>> savedNewsResourceIds: Flow<Set<String>>
): Flow<List<SaveableNewsResource>> = ): Flow<List<UserNewsResource>> =
filterNot { it.isEmpty() } filterNot { it.isEmpty() }
.combine(savedNewsResourceIds) { newsResources, savedNewsResourceIds -> .combine(savedNewsResourceIds) { newsResources, savedNewsResourceIds ->
newsResources.map { newsResource -> newsResources.map { newsResource ->
SaveableNewsResource( UserNewsResource(
newsResource = newsResource, newsResource = newsResource,
isSaved = savedNewsResourceIds.contains(newsResource.id) isSaved = savedNewsResourceIds.contains(newsResource.id)
) )

@ -21,7 +21,7 @@ import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
/** /**
* A [NewsResource] with the additional information for whether it is saved. * A [NewsResource] with the additional information for whether it is saved.
*/ */
data class SaveableNewsResource( data class UserNewsResource(
val newsResource: NewsResource, val newsResource: NewsResource,
val isSaved: Boolean, val isSaved: Boolean,
) )

@ -16,7 +16,7 @@
package com.google.samples.apps.nowinandroid.core.domain package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
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.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
@ -30,7 +30,7 @@ import kotlinx.datetime.Instant
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
class GetSaveableNewsResourcesUseCaseTest { class GetUserNewsResourcesUseCaseTest {
@get:Rule @get:Rule
val mainDispatcherRule = MainDispatcherRule() val mainDispatcherRule = MainDispatcherRule()
@ -55,9 +55,9 @@ class GetSaveableNewsResourcesUseCaseTest {
// Check that the correct news resources are returned with their bookmarked state. // Check that the correct news resources are returned with their bookmarked state.
assertEquals( assertEquals(
listOf( listOf(
SaveableNewsResource(sampleNewsResources[0], true), UserNewsResource(sampleNewsResources[0], true),
SaveableNewsResource(sampleNewsResources[1], false), UserNewsResource(sampleNewsResources[1], false),
SaveableNewsResource(sampleNewsResources[2], true) UserNewsResource(sampleNewsResources[2], true)
), ),
saveableNewsResources.first() saveableNewsResources.first()
) )
@ -77,7 +77,7 @@ class GetSaveableNewsResourcesUseCaseTest {
assertEquals( assertEquals(
sampleNewsResources sampleNewsResources
.filter { it.topics.contains(sampleTopic1) } .filter { it.topics.contains(sampleTopic1) }
.map { SaveableNewsResource(it, false) }, .map { UserNewsResource(it, false) },
saveableNewsResources.first() saveableNewsResources.first()
) )
} }

@ -37,7 +37,7 @@ import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
/** /**
@ -100,7 +100,7 @@ sealed interface NewsFeedUiState {
/** /**
* The list of news resources contained in this feed. * The list of news resources contained in this feed.
*/ */
val feed: List<SaveableNewsResource> val feed: List<UserNewsResource>
) : NewsFeedUiState ) : NewsFeedUiState
} }
@ -126,7 +126,7 @@ fun NewsFeedContentPreview() {
newsFeed( newsFeed(
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
previewNewsResources.map { previewNewsResources.map {
SaveableNewsResource( UserNewsResource(
it, it,
false false
) )

@ -31,7 +31,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import kotlin.test.assertEquals import kotlin.test.assertEquals
@ -71,7 +71,7 @@ class BookmarksScreenTest {
BookmarksScreen( BookmarksScreen(
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
previewNewsResources.take(2) previewNewsResources.take(2)
.map { SaveableNewsResource(it, true) } .map { UserNewsResource(it, true) }
), ),
removeFromBookmarks = { } removeFromBookmarks = { }
) )
@ -110,7 +110,7 @@ class BookmarksScreenTest {
BookmarksScreen( BookmarksScreen(
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
previewNewsResources.take(2) previewNewsResources.take(2)
.map { SaveableNewsResource(it, true) } .map { UserNewsResource(it, true) }
), ),
removeFromBookmarks = { newsResourceId -> removeFromBookmarks = { newsResourceId ->
assertEquals(previewNewsResources[0].id, newsResourceId) assertEquals(previewNewsResources[0].id, newsResourceId)

@ -52,7 +52,7 @@ import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadingWheel
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading
@ -185,7 +185,7 @@ private fun BookmarksGridPreview() {
BookmarksGrid( BookmarksGrid(
feedState = Success( feedState = Success(
previewNewsResources.map { previewNewsResources.map {
SaveableNewsResource(it, false) UserNewsResource(it, false)
} }
), ),
removeFromBookmarks = {} removeFromBookmarks = {}

@ -20,7 +20,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
@ -41,8 +41,8 @@ class BookmarksViewModel @Inject constructor(
val feedUiState: StateFlow<NewsFeedUiState> = getSaveableNewsResources() val feedUiState: StateFlow<NewsFeedUiState> = getSaveableNewsResources()
.filterNot { it.isEmpty() } .filterNot { it.isEmpty() }
.map { newsResources -> newsResources.filter(SaveableNewsResource::isSaved) } // Only show bookmarked news resources. .map { newsResources -> newsResources.filter(UserNewsResource::isSaved) } // Only show bookmarked news resources.
.map<List<SaveableNewsResource>, NewsFeedUiState>(NewsFeedUiState::Success) .map<List<UserNewsResource>, NewsFeedUiState>(NewsFeedUiState::Success)
.onStart { emit(Loading) } .onStart { emit(Loading) }
.stateIn( .stateIn(
scope = viewModelScope, scope = viewModelScope,

@ -29,7 +29,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
@ -226,7 +226,7 @@ class ForYouScreenTest {
onboardingUiState = OnboardingUiState.NotShown, onboardingUiState = OnboardingUiState.NotShown,
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
feed = previewNewsResources.map { feed = previewNewsResources.map {
SaveableNewsResource(it, false) UserNewsResource(it, false)
} }
), ),
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },

@ -83,7 +83,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaOverl
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.model.data.previewTopics import com.google.samples.apps.nowinandroid.core.model.data.previewTopics
import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews
@ -397,7 +397,7 @@ fun ForYouScreenPopulatedFeed() {
onboardingUiState = OnboardingUiState.NotShown, onboardingUiState = OnboardingUiState.NotShown,
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
feed = previewNewsResources.map { feed = previewNewsResources.map {
SaveableNewsResource(it, false) UserNewsResource(it, false)
} }
), ),
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
@ -418,7 +418,7 @@ fun ForYouScreenOfflinePopulatedFeed() {
onboardingUiState = OnboardingUiState.NotShown, onboardingUiState = OnboardingUiState.NotShown,
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
feed = previewNewsResources.map { feed = previewNewsResources.map {
SaveableNewsResource(it, false) UserNewsResource(it, false)
} }
), ),
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
@ -441,7 +441,7 @@ fun ForYouScreenTopicSelection() {
), ),
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
feed = previewNewsResources.map { feed = previewNewsResources.map {
SaveableNewsResource(it, false) UserNewsResource(it, false)
} }
), ),
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },
@ -479,7 +479,7 @@ fun ForYouScreenPopulatedAndLoading() {
onboardingUiState = OnboardingUiState.Loading, onboardingUiState = OnboardingUiState.Loading,
feedState = NewsFeedUiState.Success( feedState = NewsFeedUiState.Success(
feed = previewNewsResources.map { feed = previewNewsResources.map {
SaveableNewsResource(it, false) UserNewsResource(it, false)
} }
), ),
onTopicCheckedChanged = { _, _ -> }, onTopicCheckedChanged = { _, _ -> },

@ -22,7 +22,7 @@ import com.google.samples.apps.nowinandroid.core.data.repository.UserDataReposit
import com.google.samples.apps.nowinandroid.core.data.util.SyncStatusMonitor import com.google.samples.apps.nowinandroid.core.data.util.SyncStatusMonitor
import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState
import dagger.hilt.android.lifecycle.HiltViewModel import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject import javax.inject.Inject
@ -117,6 +117,6 @@ class ForYouViewModel @Inject constructor(
} }
} }
private fun Flow<List<SaveableNewsResource>>.mapToFeedState(): Flow<NewsFeedUiState> = private fun Flow<List<UserNewsResource>>.mapToFeedState(): Flow<NewsFeedUiState> =
map<List<SaveableNewsResource>, NewsFeedUiState>(NewsFeedUiState::Success) map<List<UserNewsResource>, NewsFeedUiState>(NewsFeedUiState::Success)
.onStart { emit(NewsFeedUiState.Loading) } .onStart { emit(NewsFeedUiState.Loading) }

@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.feature.foryou
import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCase
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
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.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
@ -282,7 +282,7 @@ class ForYouViewModelTest {
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = feed =
sampleNewsResources.map { sampleNewsResources.map {
SaveableNewsResource( UserNewsResource(
newsResource = it, newsResource = it,
isSaved = false isSaved = false
) )
@ -397,11 +397,11 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( UserNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],
isSaved = false isSaved = false
), ),
SaveableNewsResource( UserNewsResource(
newsResource = sampleNewsResources[2], newsResource = sampleNewsResources[2],
isSaved = false isSaved = false
) )
@ -497,11 +497,11 @@ class ForYouViewModelTest {
assertEquals( assertEquals(
NewsFeedUiState.Success( NewsFeedUiState.Success(
feed = listOf( feed = listOf(
SaveableNewsResource( UserNewsResource(
newsResource = sampleNewsResources[1], newsResource = sampleNewsResources[1],
isSaved = true isSaved = true
), ),
SaveableNewsResource( UserNewsResource(
newsResource = sampleNewsResources[2], newsResource = sampleNewsResources[2],
isSaved = false isSaved = false
) )

@ -25,7 +25,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performScrollToNode import androidx.compose.ui.test.performScrollToNode
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
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.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
@ -101,7 +101,7 @@ class TopicScreenTest {
topicUiState = TopicUiState.Loading, topicUiState = TopicUiState.Loading,
newsUiState = NewsUiState.Success( newsUiState = NewsUiState.Success(
sampleNewsResources.mapIndexed { index, newsResource -> sampleNewsResources.mapIndexed { index, newsResource ->
SaveableNewsResource( UserNewsResource(
newsResource = newsResource, newsResource = newsResource,
isSaved = index % 2 == 0, isSaved = index % 2 == 0,
) )
@ -127,7 +127,7 @@ class TopicScreenTest {
topicUiState = TopicUiState.Success(testTopic), topicUiState = TopicUiState.Success(testTopic),
newsUiState = NewsUiState.Success( newsUiState = NewsUiState.Success(
sampleNewsResources.mapIndexed { index, newsResource -> sampleNewsResources.mapIndexed { index, newsResource ->
SaveableNewsResource( UserNewsResource(
newsResource = newsResource, newsResource = newsResource,
isSaved = index % 2 == 0, isSaved = index % 2 == 0,
) )

@ -53,7 +53,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaLoadi
import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons
import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources import com.google.samples.apps.nowinandroid.core.model.data.previewNewsResources
import com.google.samples.apps.nowinandroid.core.model.data.previewTopics import com.google.samples.apps.nowinandroid.core.model.data.previewTopics
import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews
@ -258,7 +258,7 @@ fun TopicScreenPopulated() {
topicUiState = TopicUiState.Success(FollowableTopic(previewTopics[0], false)), topicUiState = TopicUiState.Success(FollowableTopic(previewTopics[0], false)),
newsUiState = NewsUiState.Success( newsUiState = NewsUiState.Success(
previewNewsResources.mapIndexed { index, newsResource -> previewNewsResources.mapIndexed { index, newsResource ->
SaveableNewsResource( UserNewsResource(
newsResource = newsResource, newsResource = newsResource,
isSaved = index % 2 == 0, isSaved = index % 2 == 0,
) )

@ -24,7 +24,7 @@ import com.google.samples.apps.nowinandroid.core.data.repository.UserDataReposit
import com.google.samples.apps.nowinandroid.core.decoder.StringDecoder import com.google.samples.apps.nowinandroid.core.decoder.StringDecoder
import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase import com.google.samples.apps.nowinandroid.core.domain.GetSaveableNewsResourcesUseCase
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
import com.google.samples.apps.nowinandroid.core.domain.model.SaveableNewsResource import com.google.samples.apps.nowinandroid.core.domain.model.UserNewsResource
import com.google.samples.apps.nowinandroid.core.model.data.Topic import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.result.Result import com.google.samples.apps.nowinandroid.core.result.Result
import com.google.samples.apps.nowinandroid.core.result.asResult import com.google.samples.apps.nowinandroid.core.result.asResult
@ -135,7 +135,7 @@ private fun newsUiState(
userDataRepository: UserDataRepository, userDataRepository: UserDataRepository,
): Flow<NewsUiState> { ): Flow<NewsUiState> {
// Observe news // Observe news
val news: Flow<List<SaveableNewsResource>> = getSaveableNewsResources( val news: Flow<List<UserNewsResource>> = getSaveableNewsResources(
filterTopicIds = setOf(element = topicId), filterTopicIds = setOf(element = topicId),
) )
@ -172,7 +172,7 @@ sealed interface TopicUiState {
} }
sealed interface NewsUiState { sealed interface NewsUiState {
data class Success(val news: List<SaveableNewsResource>) : NewsUiState data class Success(val news: List<UserNewsResource>) : NewsUiState
object Error : NewsUiState object Error : NewsUiState
object Loading : NewsUiState object Loading : NewsUiState
} }

Loading…
Cancel
Save