Skip to content

Commit

Permalink
Merge branch 'feature/ui_updates' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Dec 21, 2023
2 parents b908d99 + 6bc6111 commit 1659dd4
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class WalletConnectSignViewController: UIViewController, BottomSheetCustomFixedP

self.hideLoadingModal(completion: { [weak self] in
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
self?.presentingViewController?.dismiss(animated: true)
self?.presentingViewController?.dismiss(animated: true, completion: {
HomeTabBarController.recordWalletConnectOperationAsComplete()
})
})

} catch {
Expand All @@ -103,11 +104,12 @@ class WalletConnectSignViewController: UIViewController, BottomSheetCustomFixedP
Logger.app.info("WC Reject Request: \(request.id)")
Task {
do {
try WalletConnectService.reject(topic: request.topic, requestId: request.id)
try WalletConnectService.reject(topic: request.topic, requestId: request.id, autoMarkOpComplete: false)
self.hideLoadingModal(completion: { [weak self] in
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
self?.presentingViewController?.dismiss(animated: true)
self?.presentingViewController?.dismiss(animated: true, completion: {
HomeTabBarController.recordWalletConnectOperationAsComplete()
})
})

} catch {
Expand Down
4 changes: 3 additions & 1 deletion Kukai Mobile/Modules/Home/HomeTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,9 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
Logger.app.error("WC2 error message: \(message) - error: \(error)")

self.hideLoadingView {
WalletConnectService.shared.requestDidComplete = true
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
WalletConnectService.shared.requestDidComplete = true
}
WalletConnectService.shared.proposalInProgress = false
WalletConnectService.shared.requestInProgress = false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,17 @@ class SendCollectibleConfirmViewController: UIViewController, SlideButtonDelegat
}

func dismissAndReturn() {
if isWalletConnectOp {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
} else {
if !isWalletConnectOp {
TransactionService.shared.resetAllState()
}

self.dismiss(animated: true, completion: nil)
self.dismiss(animated: true) { [weak self] in
if self?.isWalletConnectOp == true {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
}
}

(self.presentingViewController as? UINavigationController)?.popToHome()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,17 @@ class SendContractConfirmViewController: UIViewController, SlideButtonDelegate,
}

func dismissAndReturn() {
if isWalletConnectOp {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
} else {
if !isWalletConnectOp {
TransactionService.shared.resetAllState()
}

self.dismiss(animated: true, completion: nil)
self.dismiss(animated: true) { [weak self] in
if self?.isWalletConnectOp == true {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
}
}

(self.presentingViewController as? UINavigationController)?.popToHome()
}

Expand Down
13 changes: 8 additions & 5 deletions Kukai Mobile/Modules/Send/SendTokenConfirmViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,17 @@ class SendTokenConfirmViewController: UIViewController, SlideButtonDelegate, Edi
}

func dismissAndReturn() {
if isWalletConnectOp {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
} else {
if !isWalletConnectOp {
TransactionService.shared.resetAllState()
}

self.dismiss(animated: true, completion: nil)
self.dismiss(animated: true) { [weak self] in
if self?.isWalletConnectOp == true {
TransactionService.shared.resetWalletConnectState()
HomeTabBarController.recordWalletConnectOperationAsComplete()
}
}

(self.presentingViewController as? UINavigationController)?.popToHome()
}

Expand Down
14 changes: 10 additions & 4 deletions Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,14 @@ public class WalletConnectService {
TransactionService.shared.resetWalletConnectState()
}

WalletConnectService.shared.proposalInProgress = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
WalletConnectService.shared.proposalInProgress = false
}
}
}

@MainActor
public static func reject(topic: String, requestId: RPCID, clearState: Bool = true) throws {
public static func reject(topic: String, requestId: RPCID, clearState: Bool = true, autoMarkOpComplete: Bool = true) throws {
Logger.app.info("WC Reject Request topic: \(topic), id: \(requestId.description)")
Task {
try await Sign.instance.respond(topic: topic, requestId: requestId, response: .error(.init(code: 0, message: "")))
Expand All @@ -378,8 +380,12 @@ public class WalletConnectService {
TransactionService.shared.resetWalletConnectState()
}

WalletConnectService.shared.requestDidComplete = true
WalletConnectService.shared.requestInProgress = false
if autoMarkOpComplete {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
WalletConnectService.shared.requestDidComplete = true
WalletConnectService.shared.requestInProgress = false
}
}
}
}

Expand Down

0 comments on commit 1659dd4

Please sign in to comment.