Updated on 2026-08-14
This commit is contained in:
parent
a70d51e55d
commit
72989eab5a
10 changed files with 19 additions and 43 deletions
|
|
@ -336,7 +336,6 @@ internal class MarketsTokenDetailsModel @Inject constructor(
|
|||
getNewsUseCase.getNews(
|
||||
limit = RELATED_NEWS_LIMIT,
|
||||
newsListConfig = NewsListConfig(
|
||||
language = Locale.getDefault().language,
|
||||
snapshot = null,
|
||||
tokenIds = listOf(params.token.id.value),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -32,12 +32,11 @@ import com.tangem.features.feed.ui.news.details.state.NewsDetailsUM
|
|||
import com.tangem.features.feed.ui.news.details.state.RelatedTokensUM
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.logging.TangemLogger
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
import com.tangem.utils.logging.TangemLogger
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
@Stable
|
||||
|
|
@ -60,14 +59,12 @@ internal class NewsDetailsModel @Inject constructor(
|
|||
) : Model() {
|
||||
|
||||
private val params = paramsContainer.require<DefaultNewsDetailsComponent.Params>()
|
||||
private val currentLanguage = Locale.getDefault().language
|
||||
|
||||
private val newsDetailsConverter = NewsDetailsConverter(onRelatedArticleClick = ::onRelatedArticleClick)
|
||||
|
||||
private val paginationManager: NewsDetailsPaginationManager? = params.paginationConfig?.let { config ->
|
||||
NewsDetailsPaginationManager(
|
||||
getNewsListBatchFlowUseCase = getNewsListBatchFlowUseCase,
|
||||
currentLanguage = Provider { config.language },
|
||||
currentCategoryIds = Provider { config.categoryIds },
|
||||
modelScope = modelScope,
|
||||
dispatchers = dispatchers,
|
||||
|
|
@ -212,10 +209,7 @@ internal class NewsDetailsModel @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun initialPrefetch() {
|
||||
observeNewsDetailsUseCase.prefetch(
|
||||
newsIds = params.preselectedArticlesId,
|
||||
language = currentLanguage,
|
||||
).onLeft { errors ->
|
||||
observeNewsDetailsUseCase.prefetch(newsIds = params.preselectedArticlesId).onLeft { errors ->
|
||||
errors.onEach { (newsId, error) ->
|
||||
when {
|
||||
// an article is opened from deeplink and is not found
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import kotlinx.coroutines.launch
|
|||
@Suppress("LongParameterList")
|
||||
internal class NewsDetailsPaginationManager(
|
||||
private val observeNewsDetailsUseCase: ObserveNewsDetailsUseCase,
|
||||
private val currentLanguage: Provider<String>,
|
||||
getNewsListBatchFlowUseCase: GetNewsListBatchFlowUseCase,
|
||||
dispatchers: CoroutineDispatcherProvider,
|
||||
currentCategoryIds: Provider<List<Int>>,
|
||||
|
|
@ -23,7 +22,6 @@ internal class NewsDetailsPaginationManager(
|
|||
isRedesignEnabled: Boolean,
|
||||
) : NewsListBatchFlowManager(
|
||||
getNewsListBatchFlowUseCase = getNewsListBatchFlowUseCase,
|
||||
currentLanguage = currentLanguage,
|
||||
currentCategoryIds = currentCategoryIds,
|
||||
modelScope = modelScope,
|
||||
dispatchers = dispatchers,
|
||||
|
|
@ -53,10 +51,7 @@ internal class NewsDetailsPaginationManager(
|
|||
.distinctUntilChanged()
|
||||
.collect { newIds ->
|
||||
if (newIds.isNotEmpty()) {
|
||||
observeNewsDetailsUseCase.prefetch(
|
||||
newsIds = newIds,
|
||||
language = currentLanguage(),
|
||||
)
|
||||
observeNewsDetailsUseCase.prefetch(newsIds = newIds)
|
||||
_cachedPrefetchedIds.update { it + newIds }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,12 @@ import com.tangem.domain.news.usecase.GetNewsCategoriesUseCase
|
|||
import com.tangem.domain.news.usecase.GetNewsListBatchFlowUseCase
|
||||
import com.tangem.features.feed.components.news.list.DefaultNewsListComponent
|
||||
import com.tangem.features.feed.model.news.list.analytics.NewsListAnalyticsEvent
|
||||
import com.tangem.features.feed.model.news.list.statemanager.NewsListStateManager
|
||||
import com.tangem.features.feed.model.news.list.loader.NewsCategoriesLoader
|
||||
import com.tangem.features.feed.model.news.list.statemanager.NewsListBatchFlowManager
|
||||
import com.tangem.features.feed.model.news.list.statemanager.NewsListStateManager
|
||||
import com.tangem.features.feed.ui.news.list.state.NewsListState
|
||||
import com.tangem.features.feed.ui.news.list.state.NewsListUM
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.SupportedLanguages
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
|
@ -41,7 +40,6 @@ internal class NewsListModel @Inject constructor(
|
|||
|
||||
private val params = paramsContainer.require<DefaultNewsListComponent.Params>()
|
||||
private val selectedCategoryId = MutableStateFlow<Int?>(null)
|
||||
private val currentLanguage = SupportedLanguages.getCurrentSupportedLanguageCode()
|
||||
|
||||
private val categoriesLoader by lazy {
|
||||
NewsCategoriesLoader(
|
||||
|
|
@ -54,7 +52,6 @@ internal class NewsListModel @Inject constructor(
|
|||
private val batchFlowManager by lazy {
|
||||
NewsListBatchFlowManager(
|
||||
getNewsListBatchFlowUseCase = getNewsListBatchFlowUseCase,
|
||||
currentLanguage = Provider { currentLanguage },
|
||||
currentCategoryIds = Provider {
|
||||
selectedCategoryId.value?.takeIf { it > 0 }?.let { listOf(it) }.orEmpty()
|
||||
},
|
||||
|
|
@ -158,7 +155,6 @@ internal class NewsListModel @Inject constructor(
|
|||
|
||||
private fun createNewsListConfig(): NewsListConfig {
|
||||
return NewsListConfig(
|
||||
language = currentLanguage,
|
||||
snapshot = null,
|
||||
tokenIds = emptyList(),
|
||||
categoryIds = selectedCategoryId.value?.takeIf { it > 0 }?.let { listOf(it) }.orEmpty(),
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ import kotlinx.coroutines.CoroutineScope
|
|||
import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
internal open class NewsListBatchFlowManager(
|
||||
private val isRedesignEnabled: Boolean,
|
||||
getNewsListBatchFlowUseCase: GetNewsListBatchFlowUseCase,
|
||||
private val currentLanguage: Provider<String>,
|
||||
private val currentCategoryIds: Provider<List<Int>>,
|
||||
protected val modelScope: CoroutineScope,
|
||||
protected val dispatchers: CoroutineDispatcherProvider,
|
||||
|
|
@ -146,7 +144,6 @@ internal open class NewsListBatchFlowManager(
|
|||
|
||||
private fun createNewsListConfig(): NewsListConfig {
|
||||
return NewsListConfig(
|
||||
language = currentLanguage(),
|
||||
snapshot = null,
|
||||
tokenIds = emptyList(),
|
||||
categoryIds = currentCategoryIds(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue