Updated on 2026-08-14
This commit is contained in:
parent
46650fac2c
commit
35253cded5
9 changed files with 79 additions and 69 deletions
|
|
@ -1,27 +1,34 @@
|
|||
package com.tangem.domain.wallets.usecase
|
||||
|
||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.domain.wallets.legacy.UserWalletsListManager
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import kotlinx.coroutines.withContext
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* Use case for retrieving wallets where automatically enabling push notifications was not applied.
|
||||
* * This use case filters out wallets that have already had push notifications automatically enabled
|
||||
* from the complete list of user wallets, returning only those wallets that still need to have
|
||||
* push notifications automatically enabled.
|
||||
* * @property userWalletsListManager Manager for user wallets list operations
|
||||
* @property userWalletsListManager Manager for user wallets list operations
|
||||
* @property userWalletsListRepository Repository for user wallets list operations
|
||||
* @property dispatchers Coroutine dispatcher provider for background operations
|
||||
*/
|
||||
class GetWalletsForAutomaticallyPushEnablingUseCase @Inject constructor(
|
||||
class GetWalletsForAutomaticallyPushEnablingUseCase(
|
||||
private val userWalletsListManager: UserWalletsListManager,
|
||||
private val userWalletsListRepository: UserWalletsListRepository,
|
||||
private val shouldUseNewListRepository: Boolean,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
) {
|
||||
|
||||
suspend operator fun invoke(walletsListWherePushWasEnabled: List<UserWalletId>): List<UserWalletId> =
|
||||
withContext(dispatchers.default) {
|
||||
val allLocalWallets = userWalletsListManager.userWalletsSync.map { it.walletId }
|
||||
val allLocalWallets = if (shouldUseNewListRepository) {
|
||||
userWalletsListRepository.userWalletsSync().map { it.walletId }
|
||||
} else {
|
||||
userWalletsListManager.userWalletsSync.map { it.walletId }
|
||||
}
|
||||
allLocalWallets - walletsListWherePushWasEnabled.toSet()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue