From 5a62376bfa1dbb57163af809ce23beef635e27be Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 22 Oct 2025 15:42:04 +0400 Subject: [PATCH] Updated on 2026-08-14 --- core/res/src/main/res/values-de/strings.xml | 1 + core/res/src/main/res/values-ja/strings.xml | 47 ++++++---- core/res/src/main/res/values-ru/strings.xml | 5 +- .../src/main/res/values-uk-rUA/strings.xml | 1 + core/res/src/main/res/values/strings.xml | 60 +++++++------ .../DefaultAccountsCRUDRepository.kt | 8 +- .../DefaultAccountsCRUDRepositoryTest.kt | 36 ++++---- .../repository/AccountsCRUDRepository.kt | 9 +- .../GetUnoccupiedAccountIndexUseCase.kt | 2 +- .../usecase/IsAccountsModeEnabledUseCase.kt | 5 +- .../GetUnoccupiedAccountIndexUseCaseTest.kt | 12 +-- .../IsAccountsModeEnabledUseCaseTest.kt | 37 ++++---- .../archived/ArchivedAccountListModel.kt | 88 +++++++++---------- .../entity/AccountArchivedUMBuilder.kt | 8 +- .../preview/PreviewWalletSettingsComponent.kt | 1 - .../model/WalletSettingsModel.kt | 21 +++-- .../utils/AccountItemsDelegate.kt | 12 ++- .../walletsettings/utils/ItemsBuilder.kt | 4 - 18 files changed, 194 insertions(+), 163 deletions(-) diff --git a/core/res/src/main/res/values-de/strings.xml b/core/res/src/main/res/values-de/strings.xml index c5d3a6d70e..ee000bb82f 100644 --- a/core/res/src/main/res/values-de/strings.xml +++ b/core/res/src/main/res/values-de/strings.xml @@ -1679,6 +1679,7 @@ Der erhaltene Betrag %1$s %2$s wurde nicht auf Aave eingezahlt. Aktuelle Gebühr Maximale Gebühr + Dies ist die niedrigste Einzahlung, die an Aave gesendet werden kann. Um Einzahlungen rentabel zu halten, verarbeiten wir sie nicht, wenn die Netzwerkgebühren 4 % des Betrags übersteigen. Gebührenpolitik Die Netzwerkgebühr ist derzeit zu hoch. Warte, bis sie unter Dein Limit fällt. Historische Renditen diff --git a/core/res/src/main/res/values-ja/strings.xml b/core/res/src/main/res/values-ja/strings.xml index 16107ea2c1..e23ac2ff8f 100644 --- a/core/res/src/main/res/values-ja/strings.xml +++ b/core/res/src/main/res/values-ja/strings.xml @@ -30,6 +30,7 @@ このアカウントをアーカイブしますが、いつでも復元できます。 アカウント アカウントが保存されました + 報酬用のアカウント アカウント番号%s — アドレス導出に使用されます。 アカウントを追加 保存 @@ -545,6 +546,7 @@ その他の方法 秘密鍵をオフラインで安全に保存する物理デバイス。 リカバリーフレーズ + ウォレットをハードウェアにアップグレードするには、まずバックアップしてください。 鍵はアプリに保存されます シードフレーズのバックアップ モバイルウォレットを作成する @@ -969,6 +971,10 @@ このカードを使用して、現在のウォレットの他のカードのアクセスコードを回復させられないことを認識しています。 工場出荷時設定にリセットすると、選択したカードやリングからウォレットが完全に削除されます。現在のウォレットを復元したり、カードやリングを使用してアクセスコードを復元することはできません。 工場出荷時の状態にリセットすると、選択したカードやリングからウォレットが完全に削除され、アプリから削除されます。現在のウォレットを復元することはできません。 + すべてのTangemデバイスがリセットされました。 + アクティベーション処理中に問題が発生しました。カードを1枚ずつリセットしてください。 + カード認証に失敗しました + 続行するには次のデバイスをリセットしてください Tangem Ringユーザーは、11/15日までChangelly経由でスワップを3回手数料ゼロで行えます! 今すぐ手数料0% でスワップしましょう! アプリにログインして、カードまたはリングをスキャンせずに残高を確認できます @@ -1298,6 +1304,8 @@ この手数料は、送金処理にかかるコストをカバーするためのものです。 出金 PINを変更する + カードは支払いの準備が整いました。 + PINコードを作成しました データの読み込みに失敗しました。しばらくしてからもう一度お試しください。 カードの一時停止 非表示 @@ -1728,8 +1736,9 @@ いいえ、すべて送信します %s XTZを減らす 次回ウォレットにチャージするときに手数料の増加を避けるには、金額を%s XTZ減らしてください。 - 資産残高に関するテキスト [プレースホルダー] - %sはAaveに預けられています + あなたの資金は現在Aaveプロトコルに供給されていますが、いつでも管理できます。 + %sはAaveに供給されています + 受け取った金額%1$s %2$sはAaveに入金されませんでした。 承認する 前回の承認に問題があったため、新しい承認が必要です。手続き方法を選択してください。 承認が必要 @@ -1743,60 +1752,62 @@ 年利%1$s%% 利用可能 現在のAPY + 貸付のために入金する際は、残高から%1$s以下のネットワーク手数料が差し引かれます。 + 現在、ネットワーク手数料が高すぎるため貸付を実行できません。手数料が%1$s以下に下がり次第、資金が供給されます。 私の資金 - あなたの%1$sはAaveに預けられ、利息が付きます。あなたは%2$sトークンを保有しており、これは残高を表し、時間の経過とともに増加します。入金すると、資金はAaveに預け入れられ、取引手数料を差し引いた利息が付きます。 + あなたの%1$sはAaveに預けられ、利息が付きます。あなたは%2$sトークンを保有しており、これは残高を表し、時間の経過とともに増加します。入金すると資金はAaveに供給され、取引手数料を差し引いた利息が付きます。 利回りを得る 総収益 Aaveへの送金 Aaveの詳細を見る - これは%sの現在の供給手数料です。実際のコストは受取画面に表示されます。 + これは%sの現在の供給手数料です。実際のコストはアクティベーションタブに表示されます。 現在の手数料 今後の%sの入金はすべて、取引手数料が差し引かれて自動的にAaveに供給されます。 ネットワーク手数料が上限手数料を超えた場合、手数料が下がるまで取引は成立しません。この制限は後で変更できます。 最大手数料 - 取引手数料は入金額の4%未満である必要があります。残高がこの条件を満たすのに十分な金額になった場合にのみ、TangemはAaveに資金を送ります。 + これがAaveに供給できる最小金額です。利回りモードの収益性を保つため、ネットワーク手数料が金額の4%を超える場合は資産を供給しません。 最低入金額 手数料ポリシー Tangemはまた、得られた利回りに対して3%のサービス手数料を差し引きます。 - ネットワーク手数料が現在高すぎます。設定した上限を下回るまで待機しています。 + ネットワーク手数料が下がるか、残高が最低必要額に達すると、資金は自動的にAaveに供給されます。 過去のリターン ここに説明を入力してください。1〜3行が理想的です。[プレースホルダー] - トークン承認が必要 + トークンの承認が必要 ネットワーク接続を確認してください ネットワーク手数料についての情報にアクセスできません アカウントへの入金はすべて自動的にAaveに貸し出されます。 - 残高は自動的に計算されます + Aaveへの自動送金 いつでも、即座に資金を送信、交換、売却できます。 いつでも資金にアクセス可能 使い方 Aaveは、総額819億ドル以上の資産を管理する分散型プロトコルです。 分散型・自己管理型 - サービスを利用することにより、プロバイダー\n %1$sおよび%2$sに同意したことになります + このサービスを利用することにより、プロバイダー\n%1$sおよび%2$sに同意するものとします。 Aave を接続 Aave %1$s%% • 変動金利 Aave 平均%s 昨年のリターン - 現在の金利は常に変動し、リアルタイムの需要と供給に基づいて、AAVEオンチェーンスマートコントラクトによって自動的に計算されます。 + 現在の金利は常に変動し、リアルタイムの需要と供給に基づいて、Aaveオンチェーンスマートコントラクトによって自動的に計算されます。 提供 金利は変動します - 入金すると、資金は自動的にAaveに送金され、利息が付き始めます。取引手数料として%s相当の少額の手数料が差し引かれます。 + 入金すると、資金は自動的にAaveに送金され、利息が付き始めます。%sが取引手数料として差し引かれます。 資産を供給する - %sはAaveに供給され、すぐに利用可能になります + %sはAaveに供給されますが、管理可能な状態のままになります。 手数料ポリシーを見る - 次回以降の入金は自動的にAaveに供給されます。 + 次回の入金は自動的にAaveに供給されます。 アクティブ 停止中 - 収益を停止する - オフにすると、Aaveから資金が引き出され、ウォレットの%sに戻され、報酬の獲得が停止されます。 + 利回りモードを無効にする + これをオフにすると、Aave からウォレットの %s に資金が引き出され、報酬の獲得が停止します。 出金金額からネットワーク手数料が差し引かれます。 供給APY APY - あなたの資産を眠らせない — 残高を運用して利息を得ましょう。 + 自分で管理しながら、資金に働かせましょう。 利息は自動的に発生します - Aaveの利回り + 利回りモード 入金の処理中 - 残高を活用 + 資産を有効活用しましょう 自動 取引のネットワーク手数料をカバーするために、 %1$s %2$sを入金してください %s手数料を支払えません diff --git a/core/res/src/main/res/values-ru/strings.xml b/core/res/src/main/res/values-ru/strings.xml index 168ba8b435..9b73434b2d 100644 --- a/core/res/src/main/res/values-ru/strings.xml +++ b/core/res/src/main/res/values-ru/strings.xml @@ -1569,6 +1569,7 @@ Нет, отправить все Уменьшить на %s XTZ Чтобы не платить повышенную комиссию при следующем пополнении кошелька, уменьшите сумму на %s XTZ + Ваши средства сейчас размещены в протоколе AAVE, но вы можете управлять ими в любое время. Ваш %s внесён в Aave Выдать разрешение Что-то пошло не так с вашим предыдущим разрешением, поэтому требуется новое. Выберите, как хотите продолжить. @@ -1592,7 +1593,7 @@ Все следующие пополнения %s автоматически поступят в Aave с удержанием комиссии за транзакцию. Если комиссия сети превысит максимальный лимит, транзакция не будет выполнена до тех пор, пока комиссия не снизится. Вы сможете изменить этот лимит позже. Максимальная комиссия - Комиссия за транзакцию должна быть ниже 4% от суммы депозита. Tangem переведёт средства в Aave, как только это условие будет выполнено. + Это минимальный депозит, который можно отправить в Aave. Чтобы депозиты оставались прибыльными, мы не обрабатываем их, когда комиссия сети превышает 4% от суммы. Минимальный депозит Политика комиссий Tangem взимает комиссию за обслуживание в размере 3% от полученного дохода. @@ -1602,7 +1603,7 @@ Проверьте ваше интернет соединение Информация о комиссии недоступна Каждое пополнение вашего адреса автоматически будет отправляться в Aave. - Ваш баланс работает автоматически + Автоперевод в AAVE Отправляйте, обменивайте или продавайте свои средства мгновенно, когда захотите. Мгновенный вывод средств Как это работает? diff --git a/core/res/src/main/res/values-uk-rUA/strings.xml b/core/res/src/main/res/values-uk-rUA/strings.xml index 4e66cabc58..b13f5ecb1d 100644 --- a/core/res/src/main/res/values-uk-rUA/strings.xml +++ b/core/res/src/main/res/values-uk-rUA/strings.xml @@ -1430,4 +1430,5 @@ Ні, відправити все Зменшити на %s XTZ Щоб не платити підвищену комісію при наступному поповненні гаманця, зменште суму на %s XTZ + Це найменший депозит, який можна надіслати в Aave. Щоб депозити залишалися прибутковими, ми не обробляємо їх, коли комісія мережі перевищує 4% від суми. diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml index fa0fd9a2ea..c32a04da24 100644 --- a/core/res/src/main/res/values/strings.xml +++ b/core/res/src/main/res/values/strings.xml @@ -23,6 +23,8 @@ Can\'t recover account Archived We couldn’t archive account. Please try again later. + This account participates in the referral program. + This account cannot be archived. We couldn’t create account. Please try again later. Account created Archive account @@ -42,6 +44,8 @@ Edit account %1$s in %2$s Main account + You have already exceeded the limit of %1$s active accounts. Archive one to recover + Can’t recover account Account recovered Long tap on an account to reorder accounts Keep Editing @@ -555,6 +559,7 @@ Other methods Physical devices that securely store your private key offline. Recovery phrase + To upgrade your wallet to hardware, back it up first. Your private keys are securely encrypted and stored on your phone Keys are stored in the app Create or restore your wallet using a recovery phrase — your built-in backup. @@ -993,7 +998,7 @@ Factory Reset will completely delete the wallet from the selected card or ring. You will not be able to restore the current wallet or use the card or ring to recover the access code. Factory Reset will completely delete the wallet from the selected card or ring and remove it from the app. You will not be able to restore the current wallet. All Tangem devices have been reset. - Something went wrong with activation process. Please reset cards one by one. + Something went wrong with the activation process. Please reset the cards one by one. Card verification failed Please reset the next device to continue Ring owners get 3 commission-free swaps on Changelly until 15.11! @@ -1326,6 +1331,8 @@ This fee goes to cover the cost of handling your transfer. Withdrawal Change PIN + The card is fully ready for payments. + PIN code created Failed to load data. Try again later. Freeze Card Hide @@ -1805,9 +1812,9 @@ No, send all Reduce by %s XTZ To avoid paying an increased commission the next time you top up your wallet, reduce the amount by %s XTZ - Text about your money in balance [PLACEHOLDER] - Your %s is deposited in Aave - The amount received, %1$s %2$s was not deposited to Aave. + Your funds are currently supplied to the Aave protocol, but you can manage them at any time. + Your %s is supplied to Aave + Supplying %1$s %2$s to Aave is pending Give Approve Something went wrong with your previous approval, so we need a new one. Choose how you’d like to proceed. Approve needed @@ -1817,66 +1824,67 @@ Text about your money in balance [PLACEHOLDER] Your %s is deposited in Aave Unable to load chart... - The amount received, %1$s %2$s was not deposited to Aave. + The amount received, %1$s %2$s was not supplied to Aave. APY %1$s%% Available Current APY - When topping up for lending, a network fee will be deducted from the amount — never more than %1$s + When topping up for lending, a network fee not exceeding %1$s will be deducted from the balance. The network fee is currently too high to execute lending. Funds will be supplied once it drops to %1$s or below. My funds - Your %1$s is now deposited in Aave and earning interest. You hold a%2$s token, which represents your balance and grows over time. When you top up, funds go to Aave to earn interest, minus a transaction fee. + Your %1$s is now deposited in Aave and earning interest. You hold a%2$s token, which represents your balance and grows over time. When you deposit more funds, they\'ll be supplied to Aave to earn interest, minus a transaction fee. Earn Total earnings Transfers to Aave Explore Aave - This is the current supply fee on %s. The live cost will be shown on the Receive Screen. + This is the current supply fee on %s. The actual cost will be shown on the activation tab. Current fee - All future %s top-ups will be supplied to Aave automatically, with the transaction fee deducted. + All future %s deposits will be supplied to Aave automatically, with the transaction fee deducted. + An approximate network fee of %1$s (%2$s) will be deducted from each future top-up, and it won’t exceed your %3$s (%4$s) limit. If network fees rise above maximum fee, the transaction won’t go through until they decrease. You can change this limit later. Maximum fee - The transaction fee must stay below 4% of your deposit. Tangem will transfer funds to Aave only once your balance is large enough to meet this condition. - Minimal top-up + The minimum amount is calculated from the current network fee to ensure it does not exceed 4%, which makes the minimum %1$s (%2$s). + Minimum top-up Fee policy - Tangem also takes a 3% service fee on the yield earned. - Your funds will be automatically transferred to Aave once network fees are lower or your balance meets the minimum required amount. + Tangem also takes a 3% service fee on yield earned. + Your funds will be automatically supplied to Aave once network fees are lower or your balance meets the minimum required amount. Historical returns Write description here. In one, two or three lines will be awesome. [PLACEHOLDER] - Some token approve needed + Token approvals needed Check your network connection Network fee info unreachable - Every top-up of your account will be lended to Aave automatically. - Your balance works automatically + Every deposit you make will be supplied to Aave automatically. + Auto-Transfer to Aave Send, swap, or sell your funds instantly, anytime you want. - Access to funds at any time + Access your funds anytime How it works? Aave is a decentralized protocol managing over $81.9 billion in total value. Decentralized and self-custodial - By using service, you agree with provider\n%1$s and %2$s + By using this service, you agree with provider\n%1$s and %2$s Connect Aave Aave %1$s%% • Variable Interest Rate Aave Avg %s - Last year returns - Current interest rate is always variable and automatically computed by AAVE on-chain smart-contract based on real-time supply and demand. + Last year\'s returns + Current interest rate is always variable and automatically computed by the Aave on-chain smart-contract, based on real-time supply and demand. Powered by Interest rate is variable - When you top up, your funds will be automatically sent to Aave to start earning interest. A small fee equal to %s will be deducted to cover the transaction. + When you top up, your funds will be automatically sent to Aave to start earning interest. %s will be deducted to cover the transaction fee. Supply assets - Your %s will be supplied to Aave and will stay instantly available + Your %s will be supplied to Aave, but will remain manageable. See fee policy - Your next top-ups will be automatically supplied to Aave. + Your next deposits will be automatically supplied to Aave. Active Paused Disable yield mode - Turning off will withdraw your funds from Aave, return them to %s in your wallet, and stop earning rewards. + Turning this off will withdraw your funds from Aave to %s in your wallet and it will stop earning rewards. The network fee will be deducted from the amount you withdraw. Supply APY APY - Let your funds work in the background while you stay in control. + Let your funds do the work while you stay in control. Interest accrues automatically Yield mode Processing your deposit - Make your balance work for you + Make your assets work for you Automatic Deposit some %1$s %2$s to cover the network fee for transactions Unable to cover %s fee diff --git a/data/account/src/main/kotlin/com/tangem/data/account/repository/DefaultAccountsCRUDRepository.kt b/data/account/src/main/kotlin/com/tangem/data/account/repository/DefaultAccountsCRUDRepository.kt index a71e7e66c3..c41e56cc31 100644 --- a/data/account/src/main/kotlin/com/tangem/data/account/repository/DefaultAccountsCRUDRepository.kt +++ b/data/account/src/main/kotlin/com/tangem/data/account/repository/DefaultAccountsCRUDRepository.kt @@ -168,17 +168,17 @@ internal class DefaultAccountsCRUDRepository( userTokensSaver.push(userWalletId = userWalletId, response = response.toUserTokensResponse()) } - override suspend fun getTotalAccountsCountSync(userWalletId: UserWalletId): Option = option { + override suspend fun getTotalActiveAccountsCountSync(userWalletId: UserWalletId): Option = option { val accountListResponse = getAccountsResponseSync(userWalletId = userWalletId) ensureNotNull(accountListResponse) - return accountListResponse.wallet.totalAccounts.toOption() + return accountListResponse.accounts.size.toOption() } - override fun getTotalAccountsCount(userWalletId: UserWalletId): Flow> { + override fun getTotalActiveAccountsCount(userWalletId: UserWalletId): Flow> { return getAccountsResponseStore(userWalletId = userWalletId).data - .map { it?.wallet?.totalAccounts.toOption() } + .map { it?.accounts?.size.toOption() } } override fun getUserWallet(userWalletId: UserWalletId): UserWallet { diff --git a/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt b/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt index 8d17be910e..f338ee9cf1 100644 --- a/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt +++ b/data/account/src/test/java/com/tangem/data/account/repository/DefaultAccountsCRUDRepositoryTest.kt @@ -644,15 +644,15 @@ class DefaultAccountsCRUDRepositoryTest { @Nested @TestInstance(TestInstance.Lifecycle.PER_CLASS) - inner class GetTotalAccountsCountSync { + inner class GetTotalActiveAccountsCountSync { @Test - fun `getTotalAccountsCountSync returns None if account list response is null`() = runTest { + fun `getTotalActiveAccountsCountSync returns None if account list response is null`() = runTest { // Arrange accountsResponseStoreFlow.value = null // Act - val actual = repository.getTotalAccountsCountSync(userWalletId) + val actual = repository.getTotalActiveAccountsCountSync(userWalletId) // Assert Truth.assertThat(actual).isEqualTo(None) @@ -664,20 +664,22 @@ class DefaultAccountsCRUDRepositoryTest { } @Test - fun `getTotalAccountsCountSync returns Some with totalAccounts when response is valid`() = runTest { + fun `getTotalActiveAccountsCountSync returns Some with totalAccounts when response is valid`() = runTest { // Arrange val totalAccounts = 5 - val response = mockk { - every { this@mockk.wallet.totalAccounts } returns totalAccounts + val response = createGetWalletAccountsResponse(userWalletId).let { + it.copy( + wallet = it.wallet.copy(totalAccounts = totalAccounts), + ) } accountsResponseStoreFlow.value = response // Act - val actual = repository.getTotalAccountsCountSync(userWalletId) + val actual = repository.getTotalActiveAccountsCountSync(userWalletId) // Assert - val expected = totalAccounts.toOption() + val expected = 1.toOption() Truth.assertThat(actual).isEqualTo(expected) verifyOrder { @@ -689,15 +691,15 @@ class DefaultAccountsCRUDRepositoryTest { @Nested @TestInstance(TestInstance.Lifecycle.PER_CLASS) - inner class GetTotalAccountsCount { + inner class GetTotalActiveAccountsCount { @Test - fun `getTotalAccountsCount emits 0 when account list response is null`() = runTest { + fun `getTotalActiveAccountsCount emits 0 when account list response is null`() = runTest { // Arrange accountsResponseStoreFlow.value = null // Act - val flow = repository.getTotalAccountsCount(userWalletId) + val flow = repository.getTotalActiveAccountsCount(userWalletId) val actual = getEmittedValues(flow) // Assert @@ -710,21 +712,23 @@ class DefaultAccountsCRUDRepositoryTest { } @Test - fun `getTotalAccountsCount emits correct value when response is valid`() = runTest { + fun `getTotalActiveAccountsCount emits correct value when response is valid`() = runTest { // Arrange val totalAccounts = 7 - val response = mockk { - every { this@mockk.wallet.totalAccounts } returns totalAccounts + val response = createGetWalletAccountsResponse(userWalletId).let { + it.copy( + wallet = it.wallet.copy(totalAccounts = totalAccounts), + ) } accountsResponseStoreFlow.value = response // Act - val flow = repository.getTotalAccountsCount(userWalletId) + val flow = repository.getTotalActiveAccountsCount(userWalletId) val actual = getEmittedValues(flow) // Assert - Truth.assertThat(actual).containsExactly(totalAccounts.toOption()) + Truth.assertThat(actual).containsExactly(1.toOption()) verifyOrder { accountsResponseStoreFactory.create(userWalletId) accountsResponseStore.data diff --git a/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt b/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt index e910bf695e..049ad091a9 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/repository/AccountsCRUDRepository.kt @@ -79,18 +79,19 @@ interface AccountsCRUDRepository { suspend fun syncTokens(userWalletId: UserWalletId) /** - * Retrieves the total count of accounts associated with a specific user wallet including archived accounts + * Retrieves the total count of active accounts associated with a specific user wallet excluding archived accounts * * @param userWalletId the unique identifier of the user wallet */ - suspend fun getTotalAccountsCountSync(userWalletId: UserWalletId): Option + suspend fun getTotalActiveAccountsCountSync(userWalletId: UserWalletId): Option /** - * Provides a flow of the total count of accounts associated with a specific user wallet including archived accounts + * Provides a flow of the total count of active accounts associated with a specific user wallet excluding + * archived accounts * * @param userWalletId the unique identifier of the user wallet */ - fun getTotalAccountsCount(userWalletId: UserWalletId): Flow> + fun getTotalActiveAccountsCount(userWalletId: UserWalletId): Flow> /** * Retrieves a user wallet by its unique identifier diff --git a/domain/account/src/main/java/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCase.kt b/domain/account/src/main/java/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCase.kt index 6e3d4faf1d..e761dd5649 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCase.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCase.kt @@ -40,7 +40,7 @@ class GetUnoccupiedAccountIndexUseCase( private suspend fun Raise.getTotalAccountsCount(userWalletId: UserWalletId): Int { return catch( - block = { crudRepository.getTotalAccountsCountSync(userWalletId = userWalletId) }, + block = { crudRepository.getTotalActiveAccountsCountSync(userWalletId = userWalletId) }, catch = { raise(Error.DataOperationFailed(cause = it)) }, ) .getOrElse { raise(Error.DataNotFound) } diff --git a/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt b/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt index 1a93dc67e5..86aa4adc9c 100644 --- a/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt +++ b/domain/account/src/main/java/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCase.kt @@ -45,18 +45,19 @@ class IsAccountsModeEnabledUseCase( // If the wallet does not support multiple currencies, we consider its account count as 0 if (!userWallet.isMultiCurrency) return@map 0 - crudRepository.getTotalAccountsCountSync(userWalletId = userWallet.walletId).getOrZero() + crudRepository.getTotalActiveAccountsCountSync(userWalletId = userWallet.walletId).getOrZero() } .isModeEnabled() } + @Suppress("UnusedFlow") private fun getTotalAccountsCountList(userWallets: List): List> { return userWallets .map { userWallet -> // If the wallet does not support multiple currencies, we consider its account count as 0 if (!userWallet.isMultiCurrency) return@map flowOf(0) - crudRepository.getTotalAccountsCount(userWalletId = userWallet.walletId) + crudRepository.getTotalActiveAccountsCount(userWalletId = userWallet.walletId) .map { maybeCount -> maybeCount.getOrZero() } } } diff --git a/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCaseTest.kt b/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCaseTest.kt index c469708e18..09fa80ad9b 100644 --- a/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCaseTest.kt +++ b/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/GetUnoccupiedAccountIndexUseCaseTest.kt @@ -31,7 +31,7 @@ class GetUnoccupiedAccountIndexUseCaseTest { @Test fun `invoke should return error if repository returns 0`() = runTest { // Arrange - coEvery { crudRepository.getTotalAccountsCountSync(userWalletId) } returns 0.toOption() + coEvery { crudRepository.getTotalActiveAccountsCountSync(userWalletId) } returns 0.toOption() // Act val actual = useCase(userWalletId = userWalletId).leftOrNull() as Error.DataOperationFailed @@ -42,13 +42,13 @@ class GetUnoccupiedAccountIndexUseCaseTest { Truth.assertThat(actual.cause).isInstanceOf(expected::class.java) Truth.assertThat(actual.cause).hasMessageThat().isEqualTo(expected.message) - coVerify { crudRepository.getTotalAccountsCountSync(userWalletId) } + coVerify { crudRepository.getTotalActiveAccountsCountSync(userWalletId) } } @Test fun `invoke should return next unoccupied index when repository returns count`() = runTest { // Arrange - coEvery { crudRepository.getTotalAccountsCountSync(userWalletId) } returns 3.toOption() + coEvery { crudRepository.getTotalActiveAccountsCountSync(userWalletId) } returns 3.toOption() // Act val actual = useCase(userWalletId = userWalletId) @@ -57,14 +57,14 @@ class GetUnoccupiedAccountIndexUseCaseTest { val expected = DerivationIndex(3) Truth.assertThat(actual).isEqualTo(expected) - coVerify { crudRepository.getTotalAccountsCountSync(userWalletId) } + coVerify { crudRepository.getTotalActiveAccountsCountSync(userWalletId) } } @Test fun `invoke should return error if repository throws exception`() = runTest { // Arrange val exception = IllegalStateException("Test error") - coEvery { crudRepository.getTotalAccountsCountSync(userWalletId) } throws exception + coEvery { crudRepository.getTotalActiveAccountsCountSync(userWalletId) } throws exception // Act val actual = useCase(userWalletId = userWalletId) @@ -73,6 +73,6 @@ class GetUnoccupiedAccountIndexUseCaseTest { val expected = Error.DataOperationFailed(exception).left() Truth.assertThat(actual).isEqualTo(expected) - coVerify { crudRepository.getTotalAccountsCountSync(userWalletId) } + coVerify { crudRepository.getTotalActiveAccountsCountSync(userWalletId) } } } \ No newline at end of file diff --git a/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt b/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt index 06b7c267d0..e5d8cfedc1 100644 --- a/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt +++ b/domain/account/src/test/kotlin/com/tangem/domain/account/usecase/IsAccountsModeEnabledUseCaseTest.kt @@ -19,6 +19,7 @@ import org.junit.jupiter.api.Nested import org.junit.jupiter.api.Test import org.junit.jupiter.api.TestInstance +@Suppress("UnusedFlow") @TestInstance(TestInstance.Lifecycle.PER_CLASS) class IsAccountsModeEnabledUseCaseTest { @@ -68,7 +69,7 @@ class IsAccountsModeEnabledUseCaseTest { accountsCRUDRepository.getUserWallets() } - verify(inverse = true) { accountsCRUDRepository.getTotalAccountsCount(any()) } + verify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCount(any()) } } @Test @@ -90,7 +91,7 @@ class IsAccountsModeEnabledUseCaseTest { accountsCRUDRepository.getUserWallets() } - verify(inverse = true) { accountsCRUDRepository.getTotalAccountsCount(any()) } + verify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCount(any()) } } @Test @@ -100,7 +101,7 @@ class IsAccountsModeEnabledUseCaseTest { every { featureToggles.isFeatureEnabled } returns true every { accountsCRUDRepository.getUserWallets() } returns flowOf(listOf(wallet)) - every { accountsCRUDRepository.getTotalAccountsCount(wallet.walletId) } returns flowOf(2.some()) + every { accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } returns flowOf(2.some()) // Act val actual = useCase.invoke().first() @@ -111,7 +112,7 @@ class IsAccountsModeEnabledUseCaseTest { verifyOrder { featureToggles.isFeatureEnabled accountsCRUDRepository.getUserWallets() - accountsCRUDRepository.getTotalAccountsCount(wallet.walletId) + accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } } @@ -122,7 +123,7 @@ class IsAccountsModeEnabledUseCaseTest { every { featureToggles.isFeatureEnabled } returns true every { accountsCRUDRepository.getUserWallets() } returns flowOf(listOf(wallet)) - every { accountsCRUDRepository.getTotalAccountsCount(wallet.walletId) } returns flowOf(none()) + every { accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } returns flowOf(none()) // Act val actual = useCase.invoke().first() @@ -133,7 +134,7 @@ class IsAccountsModeEnabledUseCaseTest { verifyOrder { featureToggles.isFeatureEnabled accountsCRUDRepository.getUserWallets() - accountsCRUDRepository.getTotalAccountsCount(wallet.walletId) + accountsCRUDRepository.getTotalActiveAccountsCount(wallet.walletId) } } @@ -145,7 +146,7 @@ class IsAccountsModeEnabledUseCaseTest { every { featureToggles.isFeatureEnabled } returns true every { accountsCRUDRepository.getUserWallets() } returns flowOf(listOf(wallet1, wallet2)) - every { accountsCRUDRepository.getTotalAccountsCount(wallet2.walletId) } returns flowOf(2.some()) + every { accountsCRUDRepository.getTotalActiveAccountsCount(wallet2.walletId) } returns flowOf(2.some()) // Act val actual = useCase.invoke().first() @@ -156,10 +157,10 @@ class IsAccountsModeEnabledUseCaseTest { verifyOrder { featureToggles.isFeatureEnabled accountsCRUDRepository.getUserWallets() - accountsCRUDRepository.getTotalAccountsCount(wallet2.walletId) + accountsCRUDRepository.getTotalActiveAccountsCount(wallet2.walletId) } - verify(inverse = true) { accountsCRUDRepository.getTotalAccountsCount(wallet1.walletId) } + verify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCount(wallet1.walletId) } } } @@ -199,7 +200,7 @@ class IsAccountsModeEnabledUseCaseTest { accountsCRUDRepository.getUserWalletsSync() } - coVerify(inverse = true) { accountsCRUDRepository.getTotalAccountsCountSync(any()) } + coVerify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCountSync(any()) } } @Test @@ -221,7 +222,7 @@ class IsAccountsModeEnabledUseCaseTest { accountsCRUDRepository.getUserWalletsSync() } - coVerify(inverse = true) { accountsCRUDRepository.getTotalAccountsCountSync(any()) } + coVerify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCountSync(any()) } } @Test @@ -231,7 +232,7 @@ class IsAccountsModeEnabledUseCaseTest { every { featureToggles.isFeatureEnabled } returns true every { accountsCRUDRepository.getUserWalletsSync() } returns listOf(wallet) - coEvery { accountsCRUDRepository.getTotalAccountsCountSync(wallet.walletId) } returns 2.some() + coEvery { accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet.walletId) } returns 2.some() // Act val actual = useCase.invokeSync() @@ -242,7 +243,7 @@ class IsAccountsModeEnabledUseCaseTest { coVerifyOrder { featureToggles.isFeatureEnabled accountsCRUDRepository.getUserWalletsSync() - accountsCRUDRepository.getTotalAccountsCountSync(wallet.walletId) + accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet.walletId) } } @@ -253,7 +254,7 @@ class IsAccountsModeEnabledUseCaseTest { every { featureToggles.isFeatureEnabled } returns true every { accountsCRUDRepository.getUserWalletsSync() } returns listOf(wallet) - coEvery { accountsCRUDRepository.getTotalAccountsCountSync(wallet.walletId) } returns none() + coEvery { accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet.walletId) } returns none() // Act val actual = useCase.invokeSync() @@ -264,7 +265,7 @@ class IsAccountsModeEnabledUseCaseTest { coVerifyOrder { featureToggles.isFeatureEnabled accountsCRUDRepository.getUserWalletsSync() - accountsCRUDRepository.getTotalAccountsCountSync(wallet.walletId) + accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet.walletId) } } @@ -276,7 +277,7 @@ class IsAccountsModeEnabledUseCaseTest { every { featureToggles.isFeatureEnabled } returns true every { accountsCRUDRepository.getUserWalletsSync() } returns listOf(wallet1, wallet2) - coEvery { accountsCRUDRepository.getTotalAccountsCountSync(wallet2.walletId) } returns 2.some() + coEvery { accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet2.walletId) } returns 2.some() // Act val actual = useCase.invokeSync() @@ -287,10 +288,10 @@ class IsAccountsModeEnabledUseCaseTest { coVerifyOrder { featureToggles.isFeatureEnabled accountsCRUDRepository.getUserWalletsSync() - accountsCRUDRepository.getTotalAccountsCountSync(wallet2.walletId) + accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet2.walletId) } - coVerify(inverse = true) { accountsCRUDRepository.getTotalAccountsCountSync(wallet1.walletId) } + coVerify(inverse = true) { accountsCRUDRepository.getTotalActiveAccountsCountSync(wallet1.walletId) } } } diff --git a/features/account/impl/src/main/java/com/tangem/features/account/archived/ArchivedAccountListModel.kt b/features/account/impl/src/main/java/com/tangem/features/account/archived/ArchivedAccountListModel.kt index 76c6acb6da..802d8672b9 100644 --- a/features/account/impl/src/main/java/com/tangem/features/account/archived/ArchivedAccountListModel.kt +++ b/features/account/impl/src/main/java/com/tangem/features/account/archived/ArchivedAccountListModel.kt @@ -1,6 +1,5 @@ package com.tangem.features.account.archived -import com.tangem.common.ui.account.toUM import com.tangem.core.analytics.api.AnalyticsExceptionHandler import com.tangem.core.analytics.models.ExceptionAnalyticsEvent import com.tangem.core.decompose.model.Model @@ -15,11 +14,8 @@ import com.tangem.core.ui.message.EventMessageAction import com.tangem.core.ui.message.ToastMessage import com.tangem.core.ui.utils.showErrorDialog import com.tangem.domain.account.models.AccountList -import com.tangem.domain.account.models.ArchivedAccount -import com.tangem.domain.account.usecase.ArchivedAccountList import com.tangem.domain.account.usecase.GetArchivedAccountsUseCase import com.tangem.domain.account.usecase.RecoverCryptoPortfolioUseCase -import com.tangem.domain.core.lce.Lce import com.tangem.domain.models.account.AccountId import com.tangem.features.account.ArchivedAccountListComponent import com.tangem.features.account.archived.entity.AccountArchivedUM @@ -30,6 +26,7 @@ import com.tangem.utils.coroutines.JobHolder import com.tangem.utils.coroutines.saveIn import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import timber.log.Timber import javax.inject.Inject @@ -61,25 +58,32 @@ internal class ArchivedAccountListModel @Inject constructor( .conflate() .distinctUntilChanged() .onEach { lce -> - val newState = when (lce) { - is Lce.Content -> umBuilder.mapContent( - accounts = lce.content, - onCloseClick = onCloseClick, - confirmRecoverDialog = { confirmRecoverDialog(it) }, - ) - is Lce.Error -> umBuilder.mapError( - throwable = lce.error, - onCloseClick = onCloseClick, - getArchivedAccounts = { getArchivedAccounts() }, - ) - is Lce.Loading -> lce.partialContent?.let { content -> + val newState = lce.fold( + ifLoading = { content -> + content ?: return@fold null + umBuilder.mapContent( accounts = content, onCloseClick = onCloseClick, - confirmRecoverDialog = { confirmRecoverDialog(it) }, + onRecoverClick = { recoverCryptoPortfolio(accountId = it.accountId) }, ) - } - } + }, + ifContent = { content -> + umBuilder.mapContent( + accounts = content, + onCloseClick = onCloseClick, + onRecoverClick = { recoverCryptoPortfolio(accountId = it.accountId) }, + ) + }, + ifError = { error -> + umBuilder.mapError( + throwable = error, + onCloseClick = onCloseClick, + getArchivedAccounts = { getArchivedAccounts() }, + ) + }, + ) + newState?.let { _uiState.value = newState } } .flowOn(dispatchers.default) @@ -87,30 +91,10 @@ internal class ArchivedAccountListModel @Inject constructor( .saveIn(getArchivedAccountsJob) } - private fun confirmRecoverDialog(account: ArchivedAccount) { - val secondAction = EventMessageAction( - title = resourceReference(R.string.common_cancel), - onClick = {}, - ) - val firstAction = EventMessageAction( - title = resourceReference(R.string.account_archived_recover), - onClick = { recoverCryptoPortfolio(account.accountId) }, - ) - messageSender.send( - DialogMessage( - title = resourceReference(R.string.account_archived_recover_dialog_title), - message = resourceReference( - id = R.string.account_archived_recover_dialog_description, - formatArgs = wrappedList(account.name.toUM().value), - ), - firstActionBuilder = { firstAction }, - secondActionBuilder = { secondAction }, - ), - ) - } - - private fun recoverCryptoPortfolio(accountId: AccountId) = modelScope.launch(dispatchers.default) { - recoverCryptoPortfolioUseCase(accountId) + private fun recoverCryptoPortfolio(accountId: AccountId) = modelScope.launch { + withContext(dispatchers.default) { + recoverCryptoPortfolioUseCase(accountId) + } .onLeft(::handleRecoverError) .onRight { showSuccessRecoverMessage() @@ -122,8 +106,22 @@ internal class ArchivedAccountListModel @Inject constructor( if (error is RecoverCryptoPortfolioUseCase.Error.AccountListRequirementsNotMet && error.cause is AccountList.Error.ExceedsMaxAccountsCount ) { - // TODO("account") show alert that max accounts count reached - // https://www.figma.com/design/09KKG4ZVuFDZhj8WLv5rGJ/%F0%9F%9A%A7-App-experience?node-id=24765-180563&t=vk6TCy4MkYol1cPb-4 + val firstAction = EventMessageAction( + title = resourceReference(R.string.common_got_it), + onClick = { }, + ) + + messageSender.send( + DialogMessage( + title = resourceReference(R.string.account_recover_limit_dialog_title), + message = resourceReference( + id = R.string.account_recover_limit_dialog_description, + formatArgs = wrappedList(AccountList.MAX_ACCOUNTS_COUNT.toString()), + ), + firstActionBuilder = { firstAction }, + ), + ) + return } diff --git a/features/account/impl/src/main/java/com/tangem/features/account/archived/entity/AccountArchivedUMBuilder.kt b/features/account/impl/src/main/java/com/tangem/features/account/archived/entity/AccountArchivedUMBuilder.kt index 1b7b801cf3..ed8d653691 100644 --- a/features/account/impl/src/main/java/com/tangem/features/account/archived/entity/AccountArchivedUMBuilder.kt +++ b/features/account/impl/src/main/java/com/tangem/features/account/archived/entity/AccountArchivedUMBuilder.kt @@ -15,15 +15,15 @@ internal class AccountArchivedUMBuilder @Inject constructor() { fun mapContent( accounts: ArchivedAccountList, onCloseClick: () -> Unit, - confirmRecoverDialog: (account: ArchivedAccount) -> Unit, + onRecoverClick: (account: ArchivedAccount) -> Unit, ) = AccountArchivedUM.Content( onCloseClick = onCloseClick, accounts = accounts - .map { account -> account.mapArchivedAccountUM(confirmRecoverDialog) } + .map { account -> account.mapArchivedAccountUM(onRecoverClick) } .toImmutableList(), ) - fun ArchivedAccount.mapArchivedAccountUM(confirmRecoverDialog: (account: ArchivedAccount) -> Unit) = + private fun ArchivedAccount.mapArchivedAccountUM(onRecoverClick: (account: ArchivedAccount) -> Unit) = ArchivedAccountUM( accountId = accountId.value, accountName = name.toUM().value, @@ -38,7 +38,7 @@ internal class AccountArchivedUMBuilder @Inject constructor() { count = networksCount, formatArgs = wrappedList(networksCount), ), - onClick = { confirmRecoverDialog(this) }, + onClick = { onRecoverClick(this) }, ) fun mapError( diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt index 53d1a92331..3addf5ea03 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/component/preview/PreviewWalletSettingsComponent.kt @@ -64,7 +64,6 @@ internal class PreviewWalletSettingsComponent : WalletSettingsComponent { onReferralClick = {}, isManageTokensAvailable = true, isNotificationsEnabled = true, - isNotificationsFeatureEnabled = true, onCheckedNotificationsChanged = {}, onNotificationsDescriptionClick = {}, isNotificationsPermissionGranted = false, diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt index a160447313..558ca3c5c2 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/model/WalletSettingsModel.kt @@ -48,11 +48,13 @@ import com.tangem.hot.sdk.model.HotWalletId import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.collections.immutable.PersistentList import kotlinx.collections.immutable.persistentListOf +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.* import kotlinx.coroutines.launch import timber.log.Timber import javax.inject.Inject +@OptIn(ExperimentalCoroutinesApi::class) @Suppress("LongParameterList", "LargeClass") @ModelScoped internal class WalletSettingsModel @Inject constructor( @@ -128,11 +130,11 @@ internal class WalletSettingsModel @Inject constructor( } fun combineUI(wallet: UserWallet) = combine( - getWalletNFTEnabledUseCase.invoke(params.userWalletId), - getWalletNotificationsEnabledUseCase(params.userWalletId), - isUpgradeWalletNotificationEnabledUseCase(params.userWalletId), - walletCardItemDelegate.cardItemFlow(wallet), - accountItemsDelegate.loadAccount(), + flow = getWalletNFTEnabledUseCase.invoke(params.userWalletId), + flow2 = getWalletNotificationsEnabledUseCase(params.userWalletId), + flow3 = isUpgradeWalletNotificationEnabledUseCase(params.userWalletId), + flow4 = walletCardItemDelegate.cardItemFlow(wallet), + flow5 = accountItemsDelegate.loadAccount(), ) { nftEnabled, notificationsEnabled, isUpgradeNotificationEnabled, cardItem, accountList -> val isWalletBackedUp = when (wallet) { is UserWallet.Hot -> wallet.backedUp @@ -145,7 +147,6 @@ internal class WalletSettingsModel @Inject constructor( cardItem = cardItem, isNFTEnabled = nftEnabled, isNotificationsEnabled = notificationsEnabled, - isNotificationsFeatureEnabled = true, isNotificationsPermissionGranted = isNotificationsPermissionGranted(), isUpgradeNotificationEnabled = isUpgradeNotificationEnabled, accountList = accountList, @@ -180,7 +181,6 @@ internal class WalletSettingsModel @Inject constructor( userWallet: UserWallet, cardItem: WalletSettingsItemUM.CardBlock, isNFTEnabled: Boolean, - isNotificationsFeatureEnabled: Boolean, isNotificationsEnabled: Boolean, isNotificationsPermissionGranted: Boolean, isUpgradeNotificationEnabled: Boolean, @@ -202,7 +202,11 @@ internal class WalletSettingsModel @Inject constructor( is UserWallet.Cold -> userWallet.scanResponse.card.backupStatus == CardDTO.BackupStatus.NoBackup is UserWallet.Hot -> false }, - isManageTokensAvailable = !accountsFeatureEnabled && isMultiCurrency, + isManageTokensAvailable = if (accountsFeatureEnabled) { + isMultiCurrency && accountList.count { it is WalletSettingsAccountsUM.Account } == 0 + } else { + isMultiCurrency + }, isNFTFeatureEnabled = isMultiCurrency, isNFTEnabled = isNFTEnabled, onCheckedNFTChange = ::onCheckedNFTChange, @@ -217,7 +221,6 @@ internal class WalletSettingsModel @Inject constructor( }, onReferralClick = { onReferralClick(userWallet) }, isNotificationsEnabled = isNotificationsEnabled, - isNotificationsFeatureEnabled = isNotificationsFeatureEnabled, isNotificationsPermissionGranted = isNotificationsPermissionGranted, onCheckedNotificationsChanged = ::onCheckedNotificationsChange, onNotificationsDescriptionClick = ::onNotificationsDescriptionClick, diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt index 93f0217d80..2c0cd637d0 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/AccountItemsDelegate.kt @@ -16,6 +16,7 @@ import com.tangem.domain.account.models.AccountList import com.tangem.domain.account.models.AccountStatusList import com.tangem.domain.account.status.producer.SingleAccountStatusListProducer import com.tangem.domain.account.status.supplier.SingleAccountStatusListSupplier +import com.tangem.domain.account.usecase.IsAccountsModeEnabledUseCase import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase @@ -40,6 +41,7 @@ internal class AccountItemsDelegate @Inject constructor( private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier, private val getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase, private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase, + private val isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase, private val accountsFeatureToggles: AccountsFeatureToggles, ) { val userWalletId = paramsContainer.require().userWalletId @@ -51,8 +53,9 @@ internal class AccountItemsDelegate @Inject constructor( flow = singleAccountStatusListSupplier(params), flow2 = getSelectedAppCurrencyUseCase.invokeOrDefault(), flow3 = getBalanceHidingSettingsUseCase.isBalanceHidden(), - ) { accountStatusList, appCurrency, isBalanceHidden -> - buildUiList(accountStatusList, appCurrency, isBalanceHidden) + flow4 = isAccountsModeEnabledUseCase(), + ) { accountStatusList, appCurrency, isBalanceHidden, isAccountsMode -> + buildUiList(accountStatusList, appCurrency, isBalanceHidden, isAccountsMode) } } @@ -60,6 +63,7 @@ internal class AccountItemsDelegate @Inject constructor( accountStatusList: AccountStatusList, appCurrency: AppCurrency, isBalanceHidden: Boolean, + isAccountsMode: Boolean, ): List = buildList { fun AccountStatus.CryptoPortfolio.mapCryptoPortfolio(): WalletSettingsAccountsUM { val accountItemUM = AccountPortfolioItemUMConverter( @@ -81,7 +85,9 @@ internal class AccountItemsDelegate @Inject constructor( text = resourceReference(R.string.common_accounts), ).let(::add) - addAll(accounts.map(::mapAccount)) + if (isAccountsMode) { + addAll(accounts.map(::mapAccount)) + } val addAccountEnabled = accounts.size < AccountList.MAX_ACCOUNTS_COUNT val showDescription = accounts.size > 1 diff --git a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt index 8375ca44c6..3d5a0e3040 100644 --- a/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt +++ b/features/wallet-settings/impl/src/main/kotlin/com/tangem/feature/walletsettings/utils/ItemsBuilder.kt @@ -38,7 +38,6 @@ internal class ItemsBuilder @Inject constructor( isNFTFeatureEnabled: Boolean, isNFTEnabled: Boolean, onCheckedNFTChange: (Boolean) -> Unit, - isNotificationsFeatureEnabled: Boolean, isNotificationsEnabled: Boolean, isNotificationsPermissionGranted: Boolean, onCheckedNotificationsChanged: (Boolean) -> Unit, @@ -74,7 +73,6 @@ internal class ItemsBuilder @Inject constructor( ) .addAll( buildNotificationItems( - isNotificationsFeatureEnabled = isNotificationsFeatureEnabled, isNotificationsPermissionGranted = isNotificationsPermissionGranted, isNotificationsEnabled = isNotificationsEnabled, onCheckedNotificationsChanged = onCheckedNotificationsChanged, @@ -103,13 +101,11 @@ internal class ItemsBuilder @Inject constructor( } private fun buildNotificationItems( - isNotificationsFeatureEnabled: Boolean, isNotificationsPermissionGranted: Boolean, isNotificationsEnabled: Boolean, onCheckedNotificationsChanged: (Boolean) -> Unit, onNotificationsDescriptionClick: () -> Unit, ): List { - if (!isNotificationsFeatureEnabled) return emptyList() return buildList { if (!isNotificationsPermissionGranted) { add(buildNotificationsPermissionItem())