Updated on 2026-08-14
This commit is contained in:
parent
a70d51e55d
commit
72989eab5a
10 changed files with 19 additions and 43 deletions
|
|
@ -7,14 +7,12 @@ import kotlinx.serialization.Serializable
|
|||
*
|
||||
[REDACTED_AUTHOR]
|
||||
*
|
||||
* @param language device locale (ex: en, ru).
|
||||
* @param snapshot id snapshot (`meta.asOf`) to stabilize responses.
|
||||
* @param tokenIds filter by tokens.
|
||||
* @param categoryIds filter by category.
|
||||
*/
|
||||
@Serializable
|
||||
data class NewsListConfig(
|
||||
val language: String,
|
||||
val snapshot: String?,
|
||||
val tokenIds: List<String> = emptyList(),
|
||||
val categoryIds: List<Int> = emptyList(),
|
||||
|
|
|
|||
|
|
@ -38,15 +38,14 @@ interface NewsRepository {
|
|||
/**
|
||||
* Fetches and caches detailed articles for provided ids in parallel.
|
||||
*/
|
||||
suspend fun fetchDetailedArticles(newsIds: Collection<Int>, language: String?): Either<Map<Int, Throwable>, Unit>
|
||||
suspend fun fetchDetailedArticles(newsIds: Collection<Int>): Either<Map<Int, Throwable>, Unit>
|
||||
|
||||
/**
|
||||
* Fetch list of trending news by limit and with correct locale and store it in runtime data store.
|
||||
*
|
||||
* @param limit
|
||||
* @param language current device locale
|
||||
*/
|
||||
suspend fun fetchTrendingNews(limit: Int, language: String?)
|
||||
suspend fun fetchTrendingNews(limit: Int)
|
||||
|
||||
/**
|
||||
* Observes trending news with runtime viewed flag support.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.tangem.domain.news.usecase
|
|||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.news.repository.NewsRepository
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Fetches trending news to store it in runtime data store.
|
||||
|
|
@ -11,10 +10,7 @@ import java.util.Locale
|
|||
class FetchTrendingNewsUseCase(private val newsRepository: NewsRepository) {
|
||||
|
||||
suspend operator fun invoke(): Either<Throwable, Unit> = Either.catch {
|
||||
newsRepository.fetchTrendingNews(
|
||||
limit = LIMIT_FOR_TRENDING_NEWS,
|
||||
language = Locale.getDefault().language,
|
||||
)
|
||||
newsRepository.fetchTrendingNews(limit = LIMIT_FOR_TRENDING_NEWS)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,6 @@ class ObserveNewsDetailsUseCase(
|
|||
/**
|
||||
* Prefetches the given article ids (can be called with current + next ids for pager preloading).
|
||||
*/
|
||||
suspend fun prefetch(newsIds: Collection<Int>, language: String?): Either<Map<Int, Throwable>, Unit> =
|
||||
repository.fetchDetailedArticles(newsIds, language)
|
||||
suspend fun prefetch(newsIds: Collection<Int>): Either<Map<Int, Throwable>, Unit> =
|
||||
repository.fetchDetailedArticles(newsIds)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue