Skip to content

Commit

Permalink
Merge branch 'feature/bug_fixes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmcl committed Jan 19, 2024
2 parents bdedce0 + 0e61934 commit b941192
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Kukai Mobile/Modules/Home/HomeTabBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
self.scanButton.addSubview(self.walletConnectActivity)

self.walletConnectActivity.startAnimating()
recheckConnectionIn3Seconds()

} else {
self.scanButton.isEnabled = true
Expand All @@ -459,6 +460,16 @@ extension HomeTabBarController: WalletConnectServiceDelegate {
}
}

private func recheckConnectionIn3Seconds() {
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 3) { [weak self] in
WalletConnectService.shared.isConnected { [weak self] connected in
if connected {
self?.connectionStatusChanged(status: .connected)
}
}
}
}

public func pairRequested() {
self.performSegue(withIdentifier: "wallet-connect-pair", sender: nil)
}
Expand Down
11 changes: 11 additions & 0 deletions Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class WalletConnectService {
public weak var delegate: WalletConnectServiceDelegate? = nil

private var bag = [AnyCancellable]()
private var tempConnectionSubscription: AnyCancellable? = nil
private static let projectId = "97f804b46f0db632c52af0556586a5f3"
private static let metadata = AppMetadata(name: "Kukai iOS",
description: "Kukai iOS",
Expand Down Expand Up @@ -171,6 +172,16 @@ public class WalletConnectService {
}
}

public func isConnected(completion: @escaping ((Bool) -> Void)) {
tempConnectionSubscription = Networking.instance.socketConnectionStatusPublisher.sink { [weak self] status in
completion(status == .connected)

self?.tempConnectionSubscription?.cancel()
}

tempConnectionSubscription?.store(in: &bag)
}



// MARK: - Queue Management
Expand Down

0 comments on commit b941192

Please sign in to comment.