Skip to content

Commit

Permalink
- bug fix: scan view controller blocking main thread on paste
Browse files Browse the repository at this point in the history
- add loading spinner to pairing on WC2
- add timer to auto fail after 10 seconds
  • Loading branch information
simonmcl committed Jan 22, 2024
1 parent e522fca commit 91d05ad
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "9af31bf32f291f9dd51cdfb2e774c5c1c8e552d5"
"revision" : "6a7d1f937117de5d88b9a936e74c64084a56be2b"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion Kukai Mobile/Controls/ScanViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@ class ScanViewController: UIViewController, AVCaptureMetadataOutputObjectsDelega
self.textfield.text = ""

} else {
captureSession.stopRunning()
found(code: stringToCheck)
}
}
Expand Down
18 changes: 11 additions & 7 deletions Kukai Mobile/Services/TransactionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -336,22 +336,26 @@ public class TransactionService {
let imageSize = TransactionService.sizeForWalletIcon(walletIconSize: size)
let currentNetwork = DependencyManager.shared.currentNetworkType

// Early exit if tezos domain
if metadata.hasDomain(onNetwork: currentNetwork) {
let image = UIImage(named: "Social_TZDomain_Color")?.resizedImage(size: imageSize) ?? UIImage()
return (image: image, title: metadata.primaryDomain(onNetwork: currentNetwork)?.domain.name ?? "", subtitle: metadata.address.truncateTezosAddress())
}

// Second Early exit if non-social wallet without domain
if metadata.type != .social {
let image = UIImage(named: "Social_TZ_1color")?.resizedImage(size: imageSize)?.withTintColor(.colorNamed("BGB4")) ?? UIImage()
var title = ""
var subtitle: String? = ""

if let nickname = metadata.walletNickname {

// If non social, check for nicknames first
title = nickname
subtitle = metadata.address.truncateTezosAddress()

} else if metadata.hasDomain(onNetwork: currentNetwork) {

// If no nicknames, check for tezos domains
let image = UIImage(named: "Social_TZDomain_Color")?.resizedImage(size: imageSize) ?? UIImage()
return (image: image, title: metadata.primaryDomain(onNetwork: currentNetwork)?.domain.name ?? "", subtitle: metadata.address.truncateTezosAddress())

} else {

// Use address
title = metadata.address.truncateTezosAddress()
subtitle = nil
}
Expand Down
16 changes: 16 additions & 0 deletions Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class WalletConnectService {
icons: ["https://wallet.kukai.app/assets/img/header-logo.svg"],
redirect: AppMetadata.Redirect(native: "kukai://", universal: nil))

private var pairingTimer: Timer? = nil

@Published public var requestDidComplete: Bool = false
@Published public var pairsAndSessionsUpdated: Bool = false

Expand Down Expand Up @@ -155,6 +157,11 @@ public class WalletConnectService {
.sink { [weak self] incomingProposalObj in
Logger.app.info("WC sessionProposalPublisher")
self?.sessionActionRequiredPublisherSubject.send((action: incomingProposalObj.proposal, context: incomingProposalObj.context))

self?.delegate?.processingIncomingDone()
self?.pairingTimer?.invalidate()
self?.pairingTimer = nil

}.store(in: &bag)

Sign.instance.sessionRequestPublisher
Expand Down Expand Up @@ -266,6 +273,12 @@ public class WalletConnectService {
return Future<Bool, Never>() { [weak self] promise in
Logger.app.info("WC pairing to \(uri.absoluteString)")

self?.delegate?.processingIncomingOperations()
self?.pairingTimer = Timer.scheduledTimer(withTimeInterval: 10, repeats: false, block: { [weak self] timer in
self?.delegateErrorOnMain(message: "No response from application. Please refresh the webpage, and try to connect again", error: nil)
self?.delegate?.processingIncomingDone()
})

Task { [weak self] in
do {
try await Pair.instance.pair(uri: uri)
Expand All @@ -274,6 +287,9 @@ public class WalletConnectService {
} catch {
Logger.app.error("WC Pairing connect error: \(error)")
self?.delegateErrorOnMain(message: "Unable to connect to Pair with dApp, due to: \(error)", error: error)
self?.delegate?.processingIncomingDone()
self?.pairingTimer?.invalidate()
self?.pairingTimer = nil
promise(.success(false))
}

Expand Down

0 comments on commit 91d05ad

Please sign in to comment.