Skip to content

Commit

Permalink
Allow opening Send module for non-synced state
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed May 6, 2024
1 parent ecc3472 commit cfd6bce
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 35 deletions.
8 changes: 0 additions & 8 deletions UnstoppableWallet/UnstoppableWallet/Models/AdapterState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ enum AdapterState {
default: return false
}
}

func spendAllowed(beforeSync: Bool) -> Bool {
switch self {
case .synced: return true
case .syncing, .customSyncing: return beforeSync ? true : false
case .stopped, .notSynced: return false
}
}
}

extension AdapterState: Equatable {
Expand Down
5 changes: 0 additions & 5 deletions UnstoppableWallet/UnstoppableWallet/Models/BalanceData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ class BalanceData: Codable, Equatable {
available
}

var sendBeforeSync: Bool {
false
}

var customStates: [CustomState] {
[]
}
Expand Down Expand Up @@ -124,7 +120,6 @@ class VerifiedBalanceData: BalanceData {
let fullBalance: Decimal

override var balanceTotal: Decimal { super.balanceTotal }
override var sendBeforeSync: Bool { true }

init(fullBalance: Decimal, available: Decimal) {
self.fullBalance = fullBalance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ struct BalanceTopViewItem {
let syncSpinnerProgress: Int?
let indefiniteSearchCircle: Bool
let failedImageViewVisible: Bool
let sendEnabled: Bool

let primaryValue: (text: String?, dimmed: Bool)?
let secondaryInfo: BalanceSecondaryInfoViewItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ class WalletTokenBalanceViewItemFactory {
if item.watchAccount {
buttons[.address] = .enabled
} else {
let sendButtonState: ButtonState = item
.state
.spendAllowed(beforeSync: item.balanceData.sendBeforeSync) ? .enabled : .disabled

buttons[.send] = sendButtonState
buttons[.send] = .enabled
buttons[.receive] = .enabled

if AppConfig.swapEnabled, wallet.token.swappable {
buttons[.swap] = sendButtonState
buttons[.swap] = .enabled
}
}
case let .cexAsset(cexAsset):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ extension WalletTokenListDataSource: ISectionDataSource {
}

subscribe(disposeBag, viewModel.noConnectionErrorSignal) { HudHelper.instance.show(banner: .noInternet) }
subscribe(disposeBag, viewModel.showSyncingSignal) { HudHelper.instance.show(banner: .attention(string: "wait_for_synchronization".localized)) }
subscribe(disposeBag, viewModel.selectWalletSignal) { [weak self] in self?.onSelect(wallet: $0) }
subscribe(disposeBag, viewModel.openSyncErrorSignal) { [weak self] in self?.openSyncError(wallet: $0, error: $1) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class WalletTokenListViewItemFactory {

private func topViewItem(item: WalletTokenListService.Item, balancePrimaryValue: BalancePrimaryValue, balanceHidden: Bool) -> BalanceTopViewItem {
let state = item.state
let sendEnabled = state.spendAllowed(beforeSync: item.balanceData.sendBeforeSync)

return BalanceTopViewItem(
isMainNet: item.isMainNet,
Expand All @@ -19,7 +18,6 @@ class WalletTokenListViewItemFactory {
syncSpinnerProgress: syncSpinnerProgress(state: state),
indefiniteSearchCircle: indefiniteSearchCircle(state: state),
failedImageViewVisible: failedImageViewVisible(state: state),
sendEnabled: sendEnabled,
primaryValue: primaryValue(item: item, balancePrimaryValue: balancePrimaryValue, balanceHidden: balanceHidden),
secondaryInfo: secondaryInfo(item: item, balancePrimaryValue: balancePrimaryValue, balanceHidden: balanceHidden)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class WalletTokenListViewModel {

private let showWarningRelay = BehaviorRelay<CancellableTitledCaution?>(value: nil)
private let noConnectionErrorRelay = PublishRelay<Void>()
private let showSyncingRelay = PublishRelay<Void>()
private let selectWalletRelay = PublishRelay<Wallet>()
private let openSyncErrorRelay = PublishRelay<(Wallet, Error)>()

Expand Down Expand Up @@ -132,10 +131,6 @@ extension WalletTokenListViewModel {
noConnectionErrorRelay.asSignal()
}

var showSyncingSignal: Signal<Void> {
showSyncingRelay.asSignal()
}

var selectWalletSignal: Signal<Wallet> {
selectWalletRelay.asSignal()
}
Expand Down Expand Up @@ -170,10 +165,6 @@ extension WalletTokenListViewModel {
onTapFailedIcon(element: item.element)
return
}
if !item.topViewItem.sendEnabled {
showSyncingRelay.accept(())
return
}
if let wallet = item.element.wallet {
selectWalletRelay.accept(wallet)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class WalletViewItemFactory {

private func topViewItem(item: WalletService.Item, balancePrimaryValue: BalancePrimaryValue, balanceHidden: Bool) -> BalanceTopViewItem {
let state = item.state
let sendEnabled = state.spendAllowed(beforeSync: item.balanceData.sendBeforeSync)

return BalanceTopViewItem(
isMainNet: item.isMainNet,
Expand All @@ -19,7 +18,6 @@ class WalletViewItemFactory {
syncSpinnerProgress: syncSpinnerProgress(state: state),
indefiniteSearchCircle: indefiniteSearchCircle(state: state),
failedImageViewVisible: failedImageViewVisible(state: state),
sendEnabled: sendEnabled,
primaryValue: balanceHidden ? nil : primaryValue(item: item, balancePrimaryValue: balancePrimaryValue),
secondaryInfo: secondaryInfo(item: item, balancePrimaryValue: balancePrimaryValue, balanceHidden: balanceHidden)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@
"balance.downloading_blocks" = "Downloading Blocks";
"balance.scanning_blocks" = "Scanning Blocks";
"balance.enhancing_transactions" = "Enhancing Transactions";
"wait_for_synchronization" = "Wait for synchronization";

"balance.searching.count" = "%@ tx";
"balance.syncing_percent" = "Syncing... %@";
Expand Down

0 comments on commit cfd6bce

Please sign in to comment.