From 6941e2082be9ee4712b8ed612ad80fdc25c1c06b Mon Sep 17 00:00:00 2001 From: magicalmeghan Date: Mon, 19 Dec 2022 09:22:47 -0800 Subject: [PATCH] Renamed SaveableNewsResource to UserNewsResource --- .../core/domain/GetSaveableNewsResourcesUseCase.kt | 8 ++++---- .../{SaveableNewsResource.kt => UserNewsResource.kt} | 2 +- ...aseTest.kt => GetUserNewsResourcesUseCaseTest.kt} | 12 ++++++------ .../samples/apps/nowinandroid/core/ui/NewsFeed.kt | 6 +++--- .../feature/bookmarks/BookmarksScreenTest.kt | 6 +++--- .../feature/bookmarks/BookmarksScreen.kt | 4 ++-- .../feature/bookmarks/BookmarksViewModel.kt | 6 +++--- .../nowinandroid/feature/foryou/ForYouScreenTest.kt | 4 ++-- .../apps/nowinandroid/feature/foryou/ForYouScreen.kt | 10 +++++----- .../nowinandroid/feature/foryou/ForYouViewModel.kt | 6 +++--- .../feature/foryou/ForYouViewModelTest.kt | 12 ++++++------ .../nowinandroid/feature/topic/TopicScreenTest.kt | 6 +++--- .../apps/nowinandroid/feature/topic/TopicScreen.kt | 4 ++-- .../nowinandroid/feature/topic/TopicViewModel.kt | 6 +++--- 14 files changed, 46 insertions(+), 46 deletions(-) rename core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/{SaveableNewsResource.kt => UserNewsResource.kt} (96%) rename core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/{GetSaveableNewsResourcesUseCaseTest.kt => GetUserNewsResourcesUseCaseTest.kt} (92%) diff --git a/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt b/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt index 4bd2fc6c3..df63a4487 100644 --- a/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt +++ b/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCase.kt @@ -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.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 javax.inject.Inject import kotlinx.coroutines.flow.Flow @@ -47,7 +47,7 @@ class GetSaveableNewsResourcesUseCase @Inject constructor( */ operator fun invoke( filterTopicIds: Set = emptySet() - ): Flow> = + ): Flow> = if (filterTopicIds.isEmpty()) { newsRepository.getNewsResources() } else { @@ -57,11 +57,11 @@ class GetSaveableNewsResourcesUseCase @Inject constructor( private fun Flow>.mapToSaveableNewsResources( savedNewsResourceIds: Flow> -): Flow> = +): Flow> = filterNot { it.isEmpty() } .combine(savedNewsResourceIds) { newsResources, savedNewsResourceIds -> newsResources.map { newsResource -> - SaveableNewsResource( + UserNewsResource( newsResource = newsResource, isSaved = savedNewsResourceIds.contains(newsResource.id) ) diff --git a/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/SaveableNewsResource.kt b/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt similarity index 96% rename from core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/SaveableNewsResource.kt rename to core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt index 6850d421f..ddd8a27f6 100644 --- a/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/SaveableNewsResource.kt +++ b/core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt @@ -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. */ -data class SaveableNewsResource( +data class UserNewsResource( val newsResource: NewsResource, val isSaved: Boolean, ) diff --git a/core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCaseTest.kt b/core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/GetUserNewsResourcesUseCaseTest.kt similarity index 92% rename from core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCaseTest.kt rename to core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/GetUserNewsResourcesUseCaseTest.kt index 876811e61..6bdbd9f34 100644 --- a/core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/GetSaveableNewsResourcesUseCaseTest.kt +++ b/core/domain/src/test/java/com/google/samples/apps/nowinandroid/core/domain/GetUserNewsResourcesUseCaseTest.kt @@ -16,7 +16,7 @@ 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.NewsResourceType.Video 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.Test -class GetSaveableNewsResourcesUseCaseTest { +class GetUserNewsResourcesUseCaseTest { @get:Rule val mainDispatcherRule = MainDispatcherRule() @@ -55,9 +55,9 @@ class GetSaveableNewsResourcesUseCaseTest { // Check that the correct news resources are returned with their bookmarked state. assertEquals( listOf( - SaveableNewsResource(sampleNewsResources[0], true), - SaveableNewsResource(sampleNewsResources[1], false), - SaveableNewsResource(sampleNewsResources[2], true) + UserNewsResource(sampleNewsResources[0], true), + UserNewsResource(sampleNewsResources[1], false), + UserNewsResource(sampleNewsResources[2], true) ), saveableNewsResources.first() ) @@ -77,7 +77,7 @@ class GetSaveableNewsResourcesUseCaseTest { assertEquals( sampleNewsResources .filter { it.topics.contains(sampleTopic1) } - .map { SaveableNewsResource(it, false) }, + .map { UserNewsResource(it, false) }, saveableNewsResources.first() ) } diff --git a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt index 55d84af2f..cf2714db7 100644 --- a/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt +++ b/core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsFeed.kt @@ -37,7 +37,7 @@ import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp 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 /** @@ -100,7 +100,7 @@ sealed interface NewsFeedUiState { /** * The list of news resources contained in this feed. */ - val feed: List + val feed: List ) : NewsFeedUiState } @@ -126,7 +126,7 @@ fun NewsFeedContentPreview() { newsFeed( feedState = NewsFeedUiState.Success( previewNewsResources.map { - SaveableNewsResource( + UserNewsResource( it, false ) diff --git a/feature/bookmarks/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreenTest.kt b/feature/bookmarks/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreenTest.kt index 1dafc5c98..3421f885a 100644 --- a/feature/bookmarks/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreenTest.kt +++ b/feature/bookmarks/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreenTest.kt @@ -31,7 +31,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick 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.ui.NewsFeedUiState import kotlin.test.assertEquals @@ -71,7 +71,7 @@ class BookmarksScreenTest { BookmarksScreen( feedState = NewsFeedUiState.Success( previewNewsResources.take(2) - .map { SaveableNewsResource(it, true) } + .map { UserNewsResource(it, true) } ), removeFromBookmarks = { } ) @@ -110,7 +110,7 @@ class BookmarksScreenTest { BookmarksScreen( feedState = NewsFeedUiState.Success( previewNewsResources.take(2) - .map { SaveableNewsResource(it, true) } + .map { UserNewsResource(it, true) } ), removeFromBookmarks = { newsResourceId -> assertEquals(previewNewsResources[0].id, newsResourceId) diff --git a/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt b/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt index 06a87bc9e..0bab4e449 100644 --- a/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt +++ b/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksScreen.kt @@ -52,7 +52,7 @@ import androidx.lifecycle.compose.ExperimentalLifecycleComposeApi import androidx.lifecycle.compose.collectAsStateWithLifecycle 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.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.ui.NewsFeedUiState import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Loading @@ -185,7 +185,7 @@ private fun BookmarksGridPreview() { BookmarksGrid( feedState = Success( previewNewsResources.map { - SaveableNewsResource(it, false) + UserNewsResource(it, false) } ), removeFromBookmarks = {} diff --git a/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt b/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt index 8223ecd1b..8ea565bfd 100644 --- a/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt +++ b/feature/bookmarks/src/main/java/com/google/samples/apps/nowinandroid/feature/bookmarks/BookmarksViewModel.kt @@ -20,7 +20,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope 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.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.Loading import dagger.hilt.android.lifecycle.HiltViewModel @@ -41,8 +41,8 @@ class BookmarksViewModel @Inject constructor( val feedUiState: StateFlow = getSaveableNewsResources() .filterNot { it.isEmpty() } - .map { newsResources -> newsResources.filter(SaveableNewsResource::isSaved) } // Only show bookmarked news resources. - .map, NewsFeedUiState>(NewsFeedUiState::Success) + .map { newsResources -> newsResources.filter(UserNewsResource::isSaved) } // Only show bookmarked news resources. + .map, NewsFeedUiState>(NewsFeedUiState::Success) .onStart { emit(Loading) } .stateIn( scope = viewModelScope, diff --git a/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt b/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt index 702a963c1..ee6e2795b 100644 --- a/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt +++ b/feature/foryou/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreenTest.kt @@ -29,7 +29,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText 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.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.previewNewsResources import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState @@ -226,7 +226,7 @@ class ForYouScreenTest { onboardingUiState = OnboardingUiState.NotShown, feedState = NewsFeedUiState.Success( feed = previewNewsResources.map { - SaveableNewsResource(it, false) + UserNewsResource(it, false) } ), onTopicCheckedChanged = { _, _ -> }, diff --git a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt index 1427aecff..e1a5b5e9e 100644 --- a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt +++ b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouScreen.kt @@ -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.theme.NiaTheme 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.previewTopics import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews @@ -397,7 +397,7 @@ fun ForYouScreenPopulatedFeed() { onboardingUiState = OnboardingUiState.NotShown, feedState = NewsFeedUiState.Success( feed = previewNewsResources.map { - SaveableNewsResource(it, false) + UserNewsResource(it, false) } ), onTopicCheckedChanged = { _, _ -> }, @@ -418,7 +418,7 @@ fun ForYouScreenOfflinePopulatedFeed() { onboardingUiState = OnboardingUiState.NotShown, feedState = NewsFeedUiState.Success( feed = previewNewsResources.map { - SaveableNewsResource(it, false) + UserNewsResource(it, false) } ), onTopicCheckedChanged = { _, _ -> }, @@ -441,7 +441,7 @@ fun ForYouScreenTopicSelection() { ), feedState = NewsFeedUiState.Success( feed = previewNewsResources.map { - SaveableNewsResource(it, false) + UserNewsResource(it, false) } ), onTopicCheckedChanged = { _, _ -> }, @@ -479,7 +479,7 @@ fun ForYouScreenPopulatedAndLoading() { onboardingUiState = OnboardingUiState.Loading, feedState = NewsFeedUiState.Success( feed = previewNewsResources.map { - SaveableNewsResource(it, false) + UserNewsResource(it, false) } ), onTopicCheckedChanged = { _, _ -> }, diff --git a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt index 800cba0d3..645566056 100644 --- a/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt +++ b/feature/foryou/src/main/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModel.kt @@ -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.domain.GetFollowableTopicsUseCase 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 dagger.hilt.android.lifecycle.HiltViewModel import javax.inject.Inject @@ -117,6 +117,6 @@ class ForYouViewModel @Inject constructor( } } -private fun Flow>.mapToFeedState(): Flow = - map, NewsFeedUiState>(NewsFeedUiState::Success) +private fun Flow>.mapToFeedState(): Flow = + map, NewsFeedUiState>(NewsFeedUiState::Success) .onStart { emit(NewsFeedUiState.Loading) } diff --git a/feature/foryou/src/test/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt b/feature/foryou/src/test/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt index ad29aba60..06b7ebe7a 100644 --- a/feature/foryou/src/test/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt +++ b/feature/foryou/src/test/java/com/google/samples/apps/nowinandroid/feature/foryou/ForYouViewModelTest.kt @@ -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.GetSaveableNewsResourcesUseCase 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.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.Topic @@ -282,7 +282,7 @@ class ForYouViewModelTest { NewsFeedUiState.Success( feed = sampleNewsResources.map { - SaveableNewsResource( + UserNewsResource( newsResource = it, isSaved = false ) @@ -397,11 +397,11 @@ class ForYouViewModelTest { assertEquals( NewsFeedUiState.Success( feed = listOf( - SaveableNewsResource( + UserNewsResource( newsResource = sampleNewsResources[1], isSaved = false ), - SaveableNewsResource( + UserNewsResource( newsResource = sampleNewsResources[2], isSaved = false ) @@ -497,11 +497,11 @@ class ForYouViewModelTest { assertEquals( NewsFeedUiState.Success( feed = listOf( - SaveableNewsResource( + UserNewsResource( newsResource = sampleNewsResources[1], isSaved = true ), - SaveableNewsResource( + UserNewsResource( newsResource = sampleNewsResources[2], isSaved = false ) diff --git a/feature/topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt b/feature/topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt index 9bef39a36..0f6d2dcc0 100644 --- a/feature/topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt +++ b/feature/topic/src/androidTest/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreenTest.kt @@ -25,7 +25,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithText 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.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.NewsResourceType.Video import com.google.samples.apps.nowinandroid.core.model.data.Topic @@ -101,7 +101,7 @@ class TopicScreenTest { topicUiState = TopicUiState.Loading, newsUiState = NewsUiState.Success( sampleNewsResources.mapIndexed { index, newsResource -> - SaveableNewsResource( + UserNewsResource( newsResource = newsResource, isSaved = index % 2 == 0, ) @@ -127,7 +127,7 @@ class TopicScreenTest { topicUiState = TopicUiState.Success(testTopic), newsUiState = NewsUiState.Success( sampleNewsResources.mapIndexed { index, newsResource -> - SaveableNewsResource( + UserNewsResource( newsResource = newsResource, isSaved = index % 2 == 0, ) diff --git a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt index 61bd13aa0..b57c96954 100644 --- a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt +++ b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicScreen.kt @@ -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.theme.NiaTheme 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.previewTopics import com.google.samples.apps.nowinandroid.core.ui.DevicePreviews @@ -258,7 +258,7 @@ fun TopicScreenPopulated() { topicUiState = TopicUiState.Success(FollowableTopic(previewTopics[0], false)), newsUiState = NewsUiState.Success( previewNewsResources.mapIndexed { index, newsResource -> - SaveableNewsResource( + UserNewsResource( newsResource = newsResource, isSaved = index % 2 == 0, ) diff --git a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt index 17096ca88..e65bc1dee 100644 --- a/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt +++ b/feature/topic/src/main/java/com/google/samples/apps/nowinandroid/feature/topic/TopicViewModel.kt @@ -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.domain.GetSaveableNewsResourcesUseCase 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.result.Result import com.google.samples.apps.nowinandroid.core.result.asResult @@ -135,7 +135,7 @@ private fun newsUiState( userDataRepository: UserDataRepository, ): Flow { // Observe news - val news: Flow> = getSaveableNewsResources( + val news: Flow> = getSaveableNewsResources( filterTopicIds = setOf(element = topicId), ) @@ -172,7 +172,7 @@ sealed interface TopicUiState { } sealed interface NewsUiState { - data class Success(val news: List) : NewsUiState + data class Success(val news: List) : NewsUiState object Error : NewsUiState object Loading : NewsUiState }