Updated on 2026-08-14
This commit is contained in:
parent
d2f28313e9
commit
96d5f31d82
4 changed files with 25 additions and 26 deletions
|
|
@ -58,7 +58,7 @@ internal class DefaultNewsRepository(
|
|||
return updateViewedStatusForNewsBatch(newsBatchFlow, context.coroutineScope)
|
||||
}
|
||||
|
||||
override fun getNews(config: NewsListConfig, limit: Int): Flow<List<ShortArticle>> {
|
||||
override fun getNews(config: NewsListConfig, limit: Int): Flow<Either<Throwable, List<ShortArticle>>> {
|
||||
return flow {
|
||||
val items = newsApi.getNews(
|
||||
page = FIRST_PAGE,
|
||||
|
|
@ -73,7 +73,7 @@ internal class DefaultNewsRepository(
|
|||
},
|
||||
onError = { error ->
|
||||
Timber.e(error, "Failed to get list of news")
|
||||
emptyList()
|
||||
throw error
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -85,8 +85,9 @@ internal class DefaultNewsRepository(
|
|||
articlesToUpdate.map { article ->
|
||||
val isViewed = viewedFlags[article.id] == true
|
||||
article.copy(viewed = isViewed)
|
||||
}.sortedBy { it.viewed }
|
||||
}.sortedBy { it.viewed }.right()
|
||||
}
|
||||
.catch { it.left() }
|
||||
}
|
||||
|
||||
override fun observeDetailedArticles(): Flow<Map<Int, DetailedArticle>> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue