Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-29 14:03:06 +01:00
parent 427c7aed11
commit f1039e9d96
4 changed files with 28 additions and 0 deletions

View file

@ -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()

View file

@ -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()
}

View file

@ -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)

View file

@ -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()