Updated on 2026-08-14
This commit is contained in:
parent
f58a422765
commit
c2e8cb82a7
39 changed files with 105 additions and 105 deletions
|
|
@ -24,7 +24,7 @@ dependencies {
|
|||
api(projects.domain.walletManager)
|
||||
api(projects.domain.wallets)
|
||||
api(projects.domain.wallets.models)
|
||||
api(projects.domain.promo)
|
||||
api(projects.domain.stories)
|
||||
|
||||
implementation(projects.domain.tokens.models)
|
||||
implementation(projects.domain.tokens)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ dependencies {
|
|||
api(projects.domain.core)
|
||||
api(projects.domain.settings)
|
||||
implementation(deps.kotlin.serialization)
|
||||
implementation(projects.domain.promo)
|
||||
implementation(projects.domain.stories)
|
||||
|
||||
/** Tests */
|
||||
testImplementation(deps.test.coroutine)
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
package com.tangem.domain.promo
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class ShouldShowStoriesUseCase(private val promoRepository: PromoRepository) {
|
||||
operator fun invoke(storyId: String): Flow<Boolean> = promoRepository.isReadyToShowStories(storyId)
|
||||
suspend fun invokeSync(storyId: String): Boolean = promoRepository.isReadyToShowStoriesSync(storyId)
|
||||
|
||||
suspend fun neverToShow(storyId: String) = promoRepository.setNeverToShowStories(storyId)
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ plugins {
|
|||
|
||||
dependencies {
|
||||
implementation(projects.domain.models)
|
||||
implementation(projects.domain.promo.models)
|
||||
implementation(projects.domain.stories.models)
|
||||
implementation(projects.domain.settings)
|
||||
implementation(projects.domain.wallets.models)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.tangem.domain.promo.models
|
||||
package com.tangem.domain.stories.models
|
||||
|
||||
data class StoryContent(
|
||||
val imageHost: String,
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package com.tangem.domain.promo
|
||||
package com.tangem.domain.stories
|
||||
|
||||
import arrow.core.Either
|
||||
import arrow.core.left
|
||||
import arrow.core.right
|
||||
import com.tangem.domain.promo.models.StoryContent
|
||||
import com.tangem.domain.promo.models.StoryContentIds
|
||||
import com.tangem.domain.stories.models.StoryContent
|
||||
import com.tangem.domain.stories.models.StoryContentIds
|
||||
import com.tangem.domain.settings.repositories.SettingsRepository
|
||||
import com.tangem.domain.settings.usercountry.models.needApplyFCARestrictions
|
||||
import kotlinx.coroutines.FlowPreview
|
||||
|
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.*
|
|||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
class GetStoryContentUseCase(
|
||||
private val promoRepository: PromoRepository,
|
||||
private val storiesRepository: StoriesRepository,
|
||||
private val settingsRepository: SettingsRepository,
|
||||
) {
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ class GetStoryContentUseCase(
|
|||
return isFCAAllowed(id).transform { isAllowed ->
|
||||
if (isAllowed) {
|
||||
emitAll(
|
||||
promoRepository.getStoryById(id)
|
||||
storiesRepository.getStoryById(id)
|
||||
.map<StoryContent?, Either<Throwable, StoryContent?>> { it.right() }
|
||||
.catch { emit(it.left()) }
|
||||
.onEmpty { emit(null.right()) },
|
||||
|
|
@ -34,7 +34,7 @@ class GetStoryContentUseCase(
|
|||
suspend fun invokeSync(id: String, refresh: Boolean = false): Either<Throwable, StoryContent?> = Either.catch {
|
||||
val isFCAAllowed = isFCAAllowed(id).firstOrNull() ?: false
|
||||
return@catch if (isFCAAllowed) {
|
||||
promoRepository.getStoryByIdSync(id, refresh)
|
||||
storiesRepository.getStoryByIdSync(id, refresh)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.domain.stories
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class ShouldShowStoriesUseCase(private val storiesRepository: StoriesRepository) {
|
||||
operator fun invoke(storyId: String): Flow<Boolean> = storiesRepository.isReadyToShowStories(storyId)
|
||||
suspend fun invokeSync(storyId: String): Boolean = storiesRepository.isReadyToShowStoriesSync(storyId)
|
||||
|
||||
suspend fun neverToShow(storyId: String) = storiesRepository.setNeverToShowStories(storyId)
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tangem.domain.promo
|
||||
package com.tangem.domain.stories
|
||||
|
||||
import com.tangem.domain.promo.models.StoryContent
|
||||
import com.tangem.domain.stories.models.StoryContent
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface PromoRepository {
|
||||
interface StoriesRepository {
|
||||
|
||||
// region Stories
|
||||
fun getStoryById(id: String): Flow<StoryContent?>
|
||||
|
|
@ -34,8 +34,8 @@ dependencies {
|
|||
implementation(projects.domain.settings)
|
||||
implementation(projects.features.swap.domain.api)
|
||||
implementation(projects.features.swap.domain.models)
|
||||
implementation(projects.domain.promo.models)
|
||||
implementation(projects.domain.promo)
|
||||
implementation(projects.domain.stories.models)
|
||||
implementation(projects.domain.stories)
|
||||
implementation(projects.domain.networks)
|
||||
implementation(projects.domain.quotes)
|
||||
implementation(projects.domain.yieldSupply.models)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ dependencies {
|
|||
implementation(projects.domain.models)
|
||||
implementation(projects.domain.txhistory.models)
|
||||
implementation(projects.domain.staking.models)
|
||||
implementation(projects.domain.promo.models)
|
||||
implementation(projects.domain.stories.models)
|
||||
|
||||
/** Other dependencies */
|
||||
implementation(deps.kotlin.serialization)
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import com.tangem.domain.models.currency.CryptoCurrency
|
|||
import com.tangem.domain.models.currency.CryptoCurrencyStatus
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.promo.PromoRepository
|
||||
import com.tangem.domain.promo.models.StoryContent
|
||||
import com.tangem.domain.promo.models.StoryContentIds
|
||||
import com.tangem.domain.stories.StoriesRepository
|
||||
import com.tangem.domain.stories.models.StoryContent
|
||||
import com.tangem.domain.stories.models.StoryContentIds
|
||||
import com.tangem.domain.staking.model.StakingAvailability
|
||||
import com.tangem.domain.staking.repositories.StakingRepository
|
||||
import com.tangem.domain.tokens.actions.CommonActionsFactory
|
||||
|
|
@ -28,14 +28,14 @@ import kotlinx.coroutines.flow.*
|
|||
* @param rampManager the manager for handling ramp state operations
|
||||
* @param walletManagersFacade the facade for managing wallet operations
|
||||
* @property stakingRepository the repository for staking-related data
|
||||
* @property promoRepository the repository for promotional content
|
||||
* @property storiesRepository the repository for stories content
|
||||
* @property dispatchers the coroutine dispatcher provider for managing concurrency
|
||||
*/
|
||||
class GetCryptoCurrencyActionsUseCase(
|
||||
rampManager: RampStateManager,
|
||||
walletManagersFacade: WalletManagersFacade,
|
||||
private val stakingRepository: StakingRepository,
|
||||
private val promoRepository: PromoRepository,
|
||||
private val storiesRepository: StoriesRepository,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) {
|
||||
|
||||
|
|
@ -127,7 +127,7 @@ class GetCryptoCurrencyActionsUseCase(
|
|||
}
|
||||
|
||||
private fun getSwapStoryContent(): Flow<StoryContent?> {
|
||||
return promoRepository.getStoryById(StoryContentIds.STORY_FIRST_TIME_SWAP.id)
|
||||
return storiesRepository.getStoryById(StoryContentIds.STORY_FIRST_TIME_SWAP.id)
|
||||
.conflate()
|
||||
.distinctUntilChanged()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue