From 7ffe8a4fa91dacc7eefb8644b7db26c8ab43c63c Mon Sep 17 00:00:00 2001 From: Zafar Ivaev Date: Thu, 27 Jul 2023 23:04:13 +0500 Subject: [PATCH] fix: remove switch --- .../CryptoSolanaAccountsAggregator.swift | 7 +++---- .../CryptoAccountsViewModel.swift | 16 ++++------------ .../NewSettings/Settings/View/SettingsView.swift | 11 ----------- 3 files changed, 7 insertions(+), 27 deletions(-) diff --git a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift index e71b223d42..d2f0625c2f 100644 --- a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift +++ b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/Aggregator/CryptoSolanaAccountsAggregator.swift @@ -11,11 +11,10 @@ struct CryptoSolanaAccountsAggregator: DataAggregator { input: ( accounts: [SolanaAccount], favourites: [String], - ignores: [String], - hideZeroBalance: Bool + ignores: [String] ) ) -> [RenderableSolanaAccount] { - let (accounts, favourites, ignores, hideZeroBalance) = input + let (accounts, favourites, ignores) = input return accounts .filter { !$0.isNFTToken && !$0.isUSDC } @@ -27,7 +26,7 @@ struct CryptoSolanaAccountsAggregator: DataAggregator { tags.insert(.favourite) } else if ignores.contains(account.address) { tags.insert(.ignore) - } else if hideZeroBalance, account.lamports == 0 { + } else if account.lamports == 0 { tags.insert(.ignore) } diff --git a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsViewModel.swift b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsViewModel.swift index 25ca7c945a..751c8312c0 100644 --- a/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsViewModel.swift +++ b/p2p_wallet/Scenes/Main/Crypto/Components/Crypto Accounts/CryptoAccountsViewModel.swift @@ -13,8 +13,6 @@ import Wormhole /// ViewModel of `CryptoAccounts` scene final class CryptoAccountsViewModel: BaseViewModel, ObservableObject { - private var defaultsDisposables: [DefaultsDisposable] = [] - // MARK: - Dependencies private let analyticsManager: AnalyticsManager @@ -27,7 +25,6 @@ final class CryptoAccountsViewModel: BaseViewModel, ObservableObject { // MARK: - Properties @Published private(set) var scrollOnTheTop = true - @Published private(set) var hideZeroBalance: Bool = Defaults.hideZeroBalances /// Accounts for claiming transfers. @Published var transferAccounts: [any RenderableAccount] = [] @@ -57,10 +54,6 @@ final class CryptoAccountsViewModel: BaseViewModel, ObservableObject { super.init() - defaultsDisposables.append(Defaults.observe(\.hideZeroBalances) { [weak self] change in - self?.hideZeroBalance = change.newValue ?? false - }) - self.bindAccounts() } @@ -83,14 +76,13 @@ final class CryptoAccountsViewModel: BaseViewModel, ObservableObject { // Solana accounts let solanaAggregator = CryptoSolanaAccountsAggregator() let solanaAccountsPublisher = Publishers - .CombineLatest4( + .CombineLatest3( solanaAccountsService.statePublisher, favouriteAccountsStore.$favourites, - favouriteAccountsStore.$ignores, - $hideZeroBalance + favouriteAccountsStore.$ignores ) - .map { state, favourites, ignores, hideZeroBalance in - solanaAggregator.transform(input: (state.value, favourites, ignores, hideZeroBalance)) + .map { state, favourites, ignores in + solanaAggregator.transform(input: (state.value, favourites, ignores)) } let cryptoAccountsAggregator = CryptoAccountsAggregator() diff --git a/p2p_wallet/Scenes/Main/NewSettings/Settings/View/SettingsView.swift b/p2p_wallet/Scenes/Main/NewSettings/Settings/View/SettingsView.swift index 361a143841..e0f20f458a 100644 --- a/p2p_wallet/Scenes/Main/NewSettings/Settings/View/SettingsView.swift +++ b/p2p_wallet/Scenes/Main/NewSettings/Settings/View/SettingsView.swift @@ -27,7 +27,6 @@ struct SettingsView: View { Group { profileSection securitySection - appearanceSection communitySection appVersionSection #if !RELEASE @@ -133,16 +132,6 @@ struct SettingsView: View { } } - private var appearanceSection: some View { - Section(header: headerText(L10n.appearance)) { - cellView(image: .hideZeroBalance, title: L10n.hideZeroBalances) { - Toggle("", isOn: $viewModel.zeroBalancesIsHidden) - .toggleStyle(SwitchToggleStyle(tint: Color(Asset.Colors.night.color))) - .labelsHidden() - } - } - } - private var communitySection: some View { Section(header: headerText("community")) { Button(