|
|
@ -27,6 +27,7 @@ import kotlinx.coroutines.flow.filterNotNull
|
|
|
|
|
|
|
|
|
|
|
|
val emptyUserData = UserData(
|
|
|
|
val emptyUserData = UserData(
|
|
|
|
bookmarkedNewsResources = emptySet(),
|
|
|
|
bookmarkedNewsResources = emptySet(),
|
|
|
|
|
|
|
|
viewedNewsResources = emptySet(),
|
|
|
|
followedTopics = emptySet(),
|
|
|
|
followedTopics = emptySet(),
|
|
|
|
themeBrand = ThemeBrand.DEFAULT,
|
|
|
|
themeBrand = ThemeBrand.DEFAULT,
|
|
|
|
darkThemeConfig = DarkThemeConfig.FOLLOW_SYSTEM,
|
|
|
|
darkThemeConfig = DarkThemeConfig.FOLLOW_SYSTEM,
|
|
|
@ -72,6 +73,21 @@ class TestUserDataRepository : UserDataRepository {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun updateNewsResourceViewed(newsResourceId: String, viewed: Boolean) {
|
|
|
|
|
|
|
|
currentUserData.let { current ->
|
|
|
|
|
|
|
|
_userData.tryEmit(
|
|
|
|
|
|
|
|
current.copy(
|
|
|
|
|
|
|
|
viewedNewsResources =
|
|
|
|
|
|
|
|
if (viewed) {
|
|
|
|
|
|
|
|
current.viewedNewsResources + newsResourceId
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
current.viewedNewsResources - newsResourceId
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override suspend fun setThemeBrand(themeBrand: ThemeBrand) {
|
|
|
|
override suspend fun setThemeBrand(themeBrand: ThemeBrand) {
|
|
|
|
currentUserData.let { current ->
|
|
|
|
currentUserData.let { current ->
|
|
|
|
_userData.tryEmit(current.copy(themeBrand = themeBrand))
|
|
|
|
_userData.tryEmit(current.copy(themeBrand = themeBrand))
|
|
|
|