Skip to content

Commit

Permalink
only display "complete" after the WC2 request has been successful
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed May 24, 2024
1 parent 07d9ad0 commit 134ad81
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
12 changes: 10 additions & 2 deletions Kukai Mobile/Modules/Send/SendAbstractConfirmViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SendAbstractConfirmViewController: UIViewController {
})
}

func handleApproval(opHash: String) {
func handleApproval(opHash: String, slideButton: SlideButton?) {
AccountViewModel.reconnectAccountActivityListenerIfNeeded()

if !isWalletConnectOp {
Expand All @@ -118,7 +118,15 @@ class SendAbstractConfirmViewController: UIViewController {

WalletConnectService.approveCurrentRequest(signature: nil, opHash: opHash, completion: { [weak self] success, error in
if success {
self?.dismissAndReturn(collapseOnly: false)

DispatchQueue.main.async {
slideButton?.markComplete(withText: "Complete")
}

// Delay for UX purposes only, just a brief delay to see the words "complete"
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
self?.dismissAndReturn(collapseOnly: false)
}

} else {
var message = "error-wc2-unrecoverable".localized()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,13 @@ class SendBatchConfirmViewController: SendAbstractConfirmViewController, SlideBu
}

DependencyManager.shared.tezosNodeClient.send(operations: selectedOperationsAndFees(), withWallet: wallet) { [weak self] sendResult in
self?.slideButton.markComplete(withText: "Complete")

switch sendResult {
case .success(let opHash):
Logger.app.info("Sent: \(opHash)")

self?.didSend = true
self?.addPendingTransaction(opHash: opHash)
self?.handleApproval(opHash: opHash)
self?.handleApproval(opHash: opHash, slideButton: self?.slideButton)

case .failure(let sendError):
self?.unblockInteraction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,12 @@ class SendCollectibleConfirmViewController: SendAbstractConfirmViewController, S
}

DependencyManager.shared.tezosNodeClient.send(operations: selectedOperationsAndFees(), withWallet: wallet) { [weak self] sendResult in
self?.slideButton.markComplete(withText: "Complete")
switch sendResult {
case .success(let opHash):
Logger.app.info("Sent: \(opHash)")
self?.didSend = true
self?.addPendingTransaction(opHash: opHash)
self?.handleApproval(opHash: opHash)
self?.handleApproval(opHash: opHash, slideButton: self?.slideButton)

case .failure(let sendError):
self?.unblockInteraction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,13 @@ class SendGenericConfirmViewController: SendAbstractConfirmViewController, Slide
}

DependencyManager.shared.tezosNodeClient.send(operations: selectedOperationsAndFees(), withWallet: wallet) { [weak self] sendResult in
self?.slideButton.markComplete(withText: "Complete")
switch sendResult {
case .success(let opHash):
Logger.app.info("Sent: \(opHash)")

self?.didSend = true
self?.addPendingTransaction(opHash: opHash)
self?.handleApproval(opHash: opHash)
self?.handleApproval(opHash: opHash, slideButton: self?.slideButton)

case .failure(let sendError):
self?.unblockInteraction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,12 @@ class SendTokenConfirmViewController: SendAbstractConfirmViewController, SlideBu
}

DependencyManager.shared.tezosNodeClient.send(operations: selectedOperationsAndFees(), withWallet: wallet) { [weak self] sendResult in
self?.slideButton.markComplete(withText: "Complete")
switch sendResult {
case .success(let opHash):
Logger.app.info("Sent: \(opHash)")
self?.didSend = true
self?.addPendingTransaction(opHash: opHash)
self?.handleApproval(opHash: opHash)
self?.handleApproval(opHash: opHash, slideButton: self?.slideButton)

case .failure(let sendError):
self?.unblockInteraction()
Expand Down
4 changes: 1 addition & 3 deletions Kukai Mobile/Modules/Stake/ConfirmStakeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,12 @@ class ConfirmStakeViewController: SendAbstractConfirmViewController, SlideButton
}

DependencyManager.shared.tezosNodeClient.send(operations: selectedOperationsAndFees(), withWallet: wallet) { [weak self] sendResult in
self?.slideButton.markComplete(withText: "Complete")

switch sendResult {
case .success(let opHash):
Logger.app.info("Sent: \(opHash)")
self?.didSend = true
self?.addPendingTransaction(opHash: opHash)
self?.handleApproval(opHash: opHash)
self?.handleApproval(opHash: opHash, slideButton: self?.slideButton)

case .failure(let sendError):
self?.unblockInteraction()
Expand Down

0 comments on commit 134ad81

Please sign in to comment.