Merge pull request #1275 from Jaehwa-Noh/rename-function

Rename function to setNewsResourceBookmarked
pull/1284/head
Alex Vanyo 8 months ago committed by GitHub
commit 78c77737c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -43,7 +43,7 @@ internal class FakeUserDataRepository @Inject constructor(
override suspend fun setTopicIdFollowed(followedTopicId: String, followed: Boolean) =
niaPreferencesDataSource.setTopicIdFollowed(followedTopicId, followed)
override suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean) {
override suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean) {
niaPreferencesDataSource.setNewsResourceBookmarked(newsResourceId, bookmarked)
}

@ -42,7 +42,7 @@ internal class OfflineFirstUserDataRepository @Inject constructor(
analyticsHelper.logTopicFollowToggled(followedTopicId, followed)
}
override suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean) {
override suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean) {
niaPreferencesDataSource.setNewsResourceBookmarked(newsResourceId, bookmarked)
analyticsHelper.logNewsResourceBookmarkToggled(
newsResourceId = newsResourceId,

@ -41,7 +41,7 @@ interface UserDataRepository {
/**
* Updates the bookmarked status for a news resource
*/
suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean)
suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean)
/**
* Updates the viewed status for a news resource

@ -133,7 +133,7 @@ class OfflineFirstUserDataRepositoryTest {
@Test
fun offlineFirstUserDataRepository_bookmark_news_resource_logic_delegates_to_nia_preferences() =
testScope.runTest {
subject.updateNewsResourceBookmark(newsResourceId = "0", bookmarked = true)
subject.setNewsResourceBookmarked(newsResourceId = "0", bookmarked = true)
assertEquals(
setOf("0"),
@ -142,7 +142,7 @@ class OfflineFirstUserDataRepositoryTest {
.first(),
)
subject.updateNewsResourceBookmark(newsResourceId = "1", bookmarked = true)
subject.setNewsResourceBookmarked(newsResourceId = "1", bookmarked = true)
assertEquals(
setOf("0", "1"),

@ -61,7 +61,7 @@ class TestUserDataRepository : UserDataRepository {
}
}
override suspend fun updateNewsResourceBookmark(newsResourceId: String, bookmarked: Boolean) {
override suspend fun setNewsResourceBookmarked(newsResourceId: String, bookmarked: Boolean) {
currentUserData.let { current ->
val bookmarkedNews = if (bookmarked) {
current.bookmarkedNewsResources + newsResourceId

@ -58,7 +58,7 @@ class BookmarksViewModel @Inject constructor(
viewModelScope.launch {
shouldDisplayUndoBookmark = true
lastRemovedBookmarkId = newsResourceId
userDataRepository.updateNewsResourceBookmark(newsResourceId, false)
userDataRepository.setNewsResourceBookmarked(newsResourceId, false)
}
}
@ -71,7 +71,7 @@ class BookmarksViewModel @Inject constructor(
fun undoBookmarkRemoval() {
viewModelScope.launch {
lastRemovedBookmarkId?.let {
userDataRepository.updateNewsResourceBookmark(it, true)
userDataRepository.setNewsResourceBookmarked(it, true)
}
}
clearUndoState()

@ -67,7 +67,7 @@ class BookmarksViewModelTest {
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.feedUiState.collect() }
newsRepository.sendNewsResources(newsResourcesTestData)
userDataRepository.updateNewsResourceBookmark(newsResourcesTestData[0].id, true)
userDataRepository.setNewsResourceBookmarked(newsResourcesTestData[0].id, true)
val item = viewModel.feedUiState.value
assertIs<Success>(item)
assertEquals(item.feed.size, 1)
@ -81,7 +81,7 @@ class BookmarksViewModelTest {
// Set the news resources to be used by this test
newsRepository.sendNewsResources(newsResourcesTestData)
// Start with the resource saved
userDataRepository.updateNewsResourceBookmark(newsResourcesTestData[0].id, true)
userDataRepository.setNewsResourceBookmarked(newsResourcesTestData[0].id, true)
// Use viewModel to remove saved resource
viewModel.removeFromSavedResources(newsResourcesTestData[0].id)
// Verify list of saved resources is now empty

@ -117,7 +117,7 @@ class ForYouViewModel @Inject constructor(
fun updateNewsResourceSaved(newsResourceId: String, isChecked: Boolean) {
viewModelScope.launch {
userDataRepository.updateNewsResourceBookmark(newsResourceId, isChecked)
userDataRepository.setNewsResourceBookmarked(newsResourceId, isChecked)
}
}

@ -81,7 +81,7 @@ class TopicViewModel @Inject constructor(
fun bookmarkNews(newsResourceId: String, bookmarked: Boolean) {
viewModelScope.launch {
userDataRepository.updateNewsResourceBookmark(newsResourceId, bookmarked)
userDataRepository.setNewsResourceBookmarked(newsResourceId, bookmarked)
}
}

Loading…
Cancel
Save