Updated on 2026-08-14

This commit is contained in:
Tangem 2025-11-25 17:17:12 +04:00
parent 52bf5cbb58
commit 9bd16deeb4
23 changed files with 245 additions and 151 deletions

View file

@ -1,7 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>CastNullableToNonNullableType:DefaultDeviceFlipDetector.kt$DefaultDeviceFlipDetector$as</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -16,11 +16,19 @@ import javax.inject.Singleton
@Singleton
class DefaultDeviceFlipDetector @Inject constructor(
@ApplicationContext context: Context,
@ApplicationContext private val context: Context,
) : DeviceFlipDetector, DefaultLifecycleObserver {
private val sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager
private val gravitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY)
private val sensorManager: SensorManager by lazy {
val manager = context.getSystemService(Context.SENSOR_SERVICE) as? SensorManager
requireNotNull(manager)
}
private val gravitySensor by lazy {
sensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY)
}
private val isResumedState = AtomicBoolean(false)
override fun onPause(owner: LifecycleOwner) {

View file

@ -1,7 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MultilineLambdaItParameter:DefaultHotWalletRepository.kt$DefaultHotWalletRepository${ it.setObjectMap( key = PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY, value = it.getObjectMap&lt;Boolean&gt;(PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY) .plus(userWalletId.stringValue to skipped), ) }</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -17,10 +17,10 @@ internal class DefaultHotWalletRepository(
.map { it[userWalletId.stringValue] == true }
override suspend fun setAccessCodeSkipped(userWalletId: UserWalletId, skipped: Boolean) {
appPreferencesStore.editData {
it.setObjectMap(
appPreferencesStore.editData { mutablePreferences ->
mutablePreferences.setObjectMap(
key = PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY,
value = it.getObjectMap<Boolean>(PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY)
value = mutablePreferences.getObjectMap<Boolean>(PreferencesKeys.ACCESS_CODE_SKIPPED_STATES_KEY)
.plus(userWalletId.stringValue to skipped),
)
}

View file

@ -79,6 +79,10 @@ internal class DefaultNetworksRepository(
}
}
override suspend fun hasCachedStatuses(userWalletId: UserWalletId): Boolean {
return networksStatusesStore.contains(userWalletId)
}
private suspend fun fetchPendingTransactions(
userWalletId: UserWalletId,
network: Network,

View file

@ -124,6 +124,10 @@ internal class DefaultNetworksStatusesStore(
}
}
override suspend fun contains(userWalletId: UserWalletId): Boolean {
return runtimeStore.getSyncOrDefault(emptyMap()).containsKey(userWalletId.stringValue)
}
private suspend fun updateInRuntime(
userWalletId: UserWalletId,
networks: Set<Network>,

View file

@ -44,4 +44,7 @@ internal interface NetworksStatusesStore {
/** Clear statuses of [networks] by [userWalletId] */
suspend fun clear(userWalletId: UserWalletId, networks: Set<Network>)
/** Check if there are statuses for given [userWalletId] */
suspend fun contains(userWalletId: UserWalletId): Boolean
}

View file

@ -19,10 +19,7 @@ import com.tangem.domain.promo.models.StoryContent
import com.tangem.feature.referral.domain.ReferralRepository
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.coroutines.runCatching
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapLatest
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
@ -41,23 +38,25 @@ internal class DefaultPromoRepository(
return appPreferencesStore.get(
key = PreferencesKeys.getShouldShowPromoKey(promoId = promoId.name),
default = true,
).map { shouldShow ->
when (promoId) {
PromoId.Referral -> runCatching {
!referralRepository.isReferralParticipant(userWalletId) && shouldShow
}.getOrDefault(false)
PromoId.Sepa -> {
val isActive = getSepaPromoBanner()?.isActive ?: false
)
.distinctUntilChanged()
.map { shouldShow ->
when (promoId) {
PromoId.Referral -> runCatching {
!referralRepository.isReferralParticipant(userWalletId) && shouldShow
}.getOrDefault(false)
PromoId.Sepa -> {
val isActive = getSepaPromoBanner()?.isActive ?: false
isActive && shouldShow
}
PromoId.VisaPresale -> {
val isActive = getVisaPromoBanner()?.isActive ?: false
isActive && shouldShow
}
PromoId.VisaPresale -> {
val isActive = getVisaPromoBanner()?.isActive ?: false
isActive && shouldShow
isActive && shouldShow
}
}
}
}
}
override fun isReadyToShowTokenPromo(promoId: PromoId): Flow<Boolean> {

View file

@ -1,7 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>MultilineLambdaItParameter:DefaultMultiQuoteStatusFetcher.kt$DefaultMultiQuoteStatusFetcher${ Timber.e(it) quotesStatusesStore.setSourceAsOnlyCache(currenciesIds = params.currenciesIds) }</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -66,8 +66,8 @@ internal class DefaultMultiQuoteStatusFetcher @Inject constructor(
quotesStatusesStore.store(values = updatedResponse.quotes)
}
.onLeft {
Timber.e(it)
.onLeft { throwable ->
Timber.e(throwable)
quotesStatusesStore.setSourceAsOnlyCache(currenciesIds = params.currenciesIds)
}

View file

@ -1,7 +0,0 @@
<?xml version="1.0" ?>
<SmellBaseline>
<ManuallySuppressedIssues/>
<CurrentIssues>
<ID>SuspendFunSwallowedCancellation:DefaultSettingsRepository.kt$DefaultSettingsRepository$runCatching</ID>
</CurrentIssues>
</SmellBaseline>

View file

@ -13,6 +13,7 @@ import com.tangem.domain.settings.repositories.SettingsRepository
import com.tangem.domain.settings.usercountry.models.GB_COUNTRY
import com.tangem.domain.settings.usercountry.models.UserCountry
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.coroutines.runSuspendCatching
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@ -153,7 +154,7 @@ internal class DefaultSettingsRepository(
}
withContext(dispatchers.io) {
val country = runCatching { tangemTechApi.getUserCountryCode() }
val country = runSuspendCatching { tangemTechApi.getUserCountryCode() }
.fold(
onSuccess = GeoResponse::code,
onFailure = { Locale.getDefault().country },