Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-08 15:57:06 +01:00
commit 67fb9ecf50
4 changed files with 46 additions and 6 deletions

View file

@ -30,7 +30,7 @@ class GetContactsUseCase(
private fun Contact.matches(query: String): Boolean { private fun Contact.matches(query: String): Boolean {
val isNameContaining = name.value.contains(other = query, ignoreCase = true) val isNameContaining = name.value.contains(other = query, ignoreCase = true)
val isAddressContaining = addresses.any { addressEntry -> val isAddressContaining = addresses.any { addressEntry ->
addressEntry.address.contains(other = query, ignoreCase = true) addressEntry.address.contains(other = query, ignoreCase = false)
} }
return isNameContaining || isAddressContaining return isNameContaining || isAddressContaining
} }

View file

@ -53,6 +53,41 @@ class GetContactsUseCaseTest {
assertThat(result).containsExactly(bob) assertThat(result).containsExactly(bob)
} }
@Test
fun `GIVEN address query matching case WHEN invoke THEN returns matching contact`() = runTest {
// Arrange
val carol = contact(name = "Carol", address = "0xAbCdEf")
every { repository.getAllContacts() } returns flowOf(listOf(alice, carol))
// Act
val result = useCase(query = "0xAbCdEf").first()
// Assert
assertThat(result).containsExactly(carol)
}
@Test
fun `GIVEN address query with different case WHEN invoke THEN returns empty`() = runTest {
// Arrange
val carol = contact(name = "Carol", address = "0xAbCdEf")
every { repository.getAllContacts() } returns flowOf(listOf(alice, carol))
// Act
val result = useCase(query = "0xabcdef").first()
// Assert
assertThat(result).isEmpty()
}
@Test
fun `GIVEN name query with different case WHEN invoke THEN returns matching contact`() = runTest {
// Act
val result = useCase(query = "ALICE").first()
// Assert
assertThat(result).containsExactly(alice)
}
@Test @Test
fun `GIVEN blank query WHEN invoke THEN returns all contacts unfiltered`() = runTest { fun `GIVEN blank query WHEN invoke THEN returns all contacts unfiltered`() = runTest {
// Act // Act

View file

@ -128,6 +128,7 @@ dependencies {
implementation(projects.domain.yieldSupply.models) implementation(projects.domain.yieldSupply.models)
/** Feature Apis */ /** Feature Apis */
api(projects.features.addressBook.api)
api(projects.features.biometry.api) api(projects.features.biometry.api)
api(projects.features.commonFeatures.api) api(projects.features.commonFeatures.api)
api(projects.features.feed.api) api(projects.features.feed.api)

View file

@ -61,6 +61,7 @@ import com.tangem.feature.wallet.presentation.wallet.state.transformers.*
import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender import com.tangem.feature.wallet.presentation.wallet.state.utils.WalletEventSender
import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.KycRejectedCallbacks import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.KycRejectedCallbacks
import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvider
import com.tangem.features.addressbook.AddressBookFeatureToggles
import com.tangem.features.biometry.AskBiometryComponent import com.tangem.features.biometry.AskBiometryComponent
import com.tangem.features.hotwallet.HotWalletFeatureToggles import com.tangem.features.hotwallet.HotWalletFeatureToggles
import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks
@ -127,6 +128,7 @@ internal class WalletModel @Inject constructor(
private val hotWalletFeatureToggles: HotWalletFeatureToggles, private val hotWalletFeatureToggles: HotWalletFeatureToggles,
private val walletFeatureToggles: WalletFeatureToggles, private val walletFeatureToggles: WalletFeatureToggles,
private val pushNotificationSettingsFeatureToggles: PushNotificationSettingsFeatureToggles, private val pushNotificationSettingsFeatureToggles: PushNotificationSettingsFeatureToggles,
private val addressBookFeatureToggles: AddressBookFeatureToggles,
private val startAssetsDiscoveryUseCase: StartAssetsDiscoveryUseCase, private val startAssetsDiscoveryUseCase: StartAssetsDiscoveryUseCase,
private val syncAddressBooksUseCase: SyncAddressBooksUseCase, private val syncAddressBooksUseCase: SyncAddressBooksUseCase,
val screenLifecycleProvider: ScreenLifecycleProvider, val screenLifecycleProvider: ScreenLifecycleProvider,
@ -164,7 +166,7 @@ internal class WalletModel @Inject constructor(
subscribeToMainScreenQrScanning() subscribeToMainScreenQrScanning()
enableNotificationsIfNeeded() enableNotificationsIfNeeded()
applyPendingAssetsDiscovery() applyPendingAssetsDiscovery()
syncAddressBooks() syncAddressBooksIfNeeded()
clickIntents.initialize(innerWalletRouter, modelScope) clickIntents.initialize(innerWalletRouter, modelScope)
@ -882,10 +884,12 @@ internal class WalletModel @Inject constructor(
} }
} }
private fun syncAddressBooks() { private fun syncAddressBooksIfNeeded() {
modelScope.launch { if (addressBookFeatureToggles.isAddressBookEnabled) {
syncAddressBooksUseCase() modelScope.launch {
.onLeft { TangemLogger.e("Failed to sync address books: $it") } syncAddressBooksUseCase()
.onLeft { TangemLogger.e("Failed to sync address books: $it") }
}
} }
} }