Skip to content

Commit

Permalink
fix: observe hide zero balances toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
zafar4aev committed Jul 25, 2023
1 parent 38e2bd2 commit 7e22618
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import Wormhole
/// ViewModel of `CryptoAccounts` scene
final class CryptoAccountsViewModel: BaseViewModel, ObservableObject {

private var defaultsDisposables: [DefaultsDisposable] = []

// MARK: - Dependencies

private let solanaAccountsService: SolanaAccountsService
Expand Down Expand Up @@ -52,6 +54,10 @@ final class CryptoAccountsViewModel: BaseViewModel, ObservableObject {

super.init()

defaultsDisposables.append(Defaults.observe(\.hideZeroBalances) { [weak self] change in
self?.hideZeroBalance = change.newValue ?? false
})

self.bindAccounts()
}

Expand Down Expand Up @@ -84,11 +90,11 @@ final class CryptoAccountsViewModel: BaseViewModel, ObservableObject {
solanaAggregator.transform(input: (state.value, favourites, ignores, hideZeroBalance))
}

let homeAccountsAggregator = CryptoAccountsAggregator()
let cryptoAccountsAggregator = CryptoAccountsAggregator()
Publishers
.CombineLatest(solanaAccountsPublisher, ethereumAccountsPublisher)
.map { solanaAccounts, ethereumAccounts in
homeAccountsAggregator.transform(input: (solanaAccounts, ethereumAccounts))
cryptoAccountsAggregator.transform(input: (solanaAccounts, ethereumAccounts))
}
.receive(on: RunLoop.main)
.sink { transfer, primary, secondary in
Expand Down

0 comments on commit 7e22618

Please sign in to comment.