From f1039e9d969797090af24db870d47b3fa6e3c02f Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 29 Jun 2026 14:03:06 +0100 Subject: [PATCH] Updated on 2026-08-14 --- .../tangem/tap/di/domain/AddressBookDomainModule.kt | 7 +++++++ .../addressbook/usecase/SyncAddressBooksUseCase.kt | 10 ++++++++++ features/wallet/impl/build.gradle.kts | 1 + .../feature/wallet/child/wallet/model/WalletModel.kt | 10 ++++++++++ 4 files changed, 28 insertions(+) create mode 100644 domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/SyncAddressBooksUseCase.kt diff --git a/app/src/main/java/com/tangem/tap/di/domain/AddressBookDomainModule.kt b/app/src/main/java/com/tangem/tap/di/domain/AddressBookDomainModule.kt index d16d61ed8a..3c7d4cab2c 100644 --- a/app/src/main/java/com/tangem/tap/di/domain/AddressBookDomainModule.kt +++ b/app/src/main/java/com/tangem/tap/di/domain/AddressBookDomainModule.kt @@ -8,6 +8,7 @@ import com.tangem.domain.addressbook.time.DefaultIsoTimestampProvider import com.tangem.domain.addressbook.time.IsoTimestampProvider import com.tangem.domain.addressbook.usecase.DeleteContactUseCase import com.tangem.domain.addressbook.usecase.GetContactsUseCase +import com.tangem.domain.addressbook.usecase.SyncAddressBooksUseCase import com.tangem.domain.addressbook.usecase.ValidateContactAddressUseCase import com.tangem.domain.addressbook.usecase.ValidateContactNameUseCase import com.tangem.domain.common.wallets.UserWalletsListRepository @@ -85,6 +86,12 @@ object AddressBookDomainModule { return DeleteContactUseCase(repository = repository) } + @Provides + @Singleton + fun provideSyncAddressBooksUseCase(repository: AddressBookRepository): SyncAddressBooksUseCase { + return SyncAddressBooksUseCase(repository = repository) + } + @Provides @Singleton fun provideAddressBookCipher(): AddressBookCipher = AddressBookCipher() diff --git a/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/SyncAddressBooksUseCase.kt b/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/SyncAddressBooksUseCase.kt new file mode 100644 index 0000000000..f0a76af9d5 --- /dev/null +++ b/domain/address-book/src/main/kotlin/com/tangem/domain/addressbook/usecase/SyncAddressBooksUseCase.kt @@ -0,0 +1,10 @@ +package com.tangem.domain.addressbook.usecase + +import com.tangem.domain.addressbook.repository.AddressBookRepository + +class SyncAddressBooksUseCase( + private val repository: AddressBookRepository, +) { + + suspend operator fun invoke() = repository.syncAddressBooks() +} \ No newline at end of file diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts index 9e06c9a21b..cc4d6ecf6b 100644 --- a/features/wallet/impl/build.gradle.kts +++ b/features/wallet/impl/build.gradle.kts @@ -81,6 +81,7 @@ dependencies { /** Domain modules */ implementation(projects.domain.account) implementation(projects.domain.account.status) + implementation(projects.domain.addressBook) implementation(projects.domain.analytics) implementation(projects.domain.appCurrency) implementation(projects.domain.appCurrency.models) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt index 8a0506515f..79ee5b4a30 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/child/wallet/model/WalletModel.kt @@ -16,6 +16,7 @@ import com.tangem.core.ui.utils.parseBigDecimal import com.tangem.datasource.local.appsflyer.AppsFlyerStore import com.tangem.domain.account.status.usecase.IsAccountsModeEnabledUseCase import com.tangem.domain.account.supplier.SingleAccountListSupplier +import com.tangem.domain.addressbook.usecase.SyncAddressBooksUseCase import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.apptheme.GetAppThemeModeUseCase @@ -127,6 +128,7 @@ internal class WalletModel @Inject constructor( private val walletFeatureToggles: WalletFeatureToggles, private val pushNotificationSettingsFeatureToggles: PushNotificationSettingsFeatureToggles, private val startAssetsDiscoveryUseCase: StartAssetsDiscoveryUseCase, + private val syncAddressBooksUseCase: SyncAddressBooksUseCase, val screenLifecycleProvider: ScreenLifecycleProvider, val innerWalletRouter: InnerWalletRouter, ) : Model() { @@ -162,6 +164,7 @@ internal class WalletModel @Inject constructor( subscribeToMainScreenQrScanning() enableNotificationsIfNeeded() applyPendingAssetsDiscovery() + syncAddressBooks() clickIntents.initialize(innerWalletRouter, modelScope) @@ -877,6 +880,13 @@ internal class WalletModel @Inject constructor( } } + private fun syncAddressBooks() { + modelScope.launch { + syncAddressBooksUseCase() + .onLeft { TangemLogger.e("Failed to sync address books: $it") } + } + } + private fun enableNotificationsIfNeeded() { modelScope.launch { val isUserAllowToEnableNotifications = notificationsRepository.isUserAllowToSubscribeOnPushNotifications()