mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-12 12:33:42 +03:00
Refactor reconnecting
This commit is contained in:
parent
81aa9c815b
commit
3e3afde86c
@ -69,9 +69,10 @@ class WalletConnect {
|
||||
interactor?.approveSession(accounts: accounts, chainId: chainId).cauterize()
|
||||
}
|
||||
|
||||
interactor.onDisconnect = { [weak interactor] _ in
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(10)) {
|
||||
interactor?.resume() // TODO: reconnect when appropriate. should not reconnect when session is killed.
|
||||
interactor.onDisconnect = { [weak interactor, weak self] _ in
|
||||
// TODO: should not reconnect when session is killed.
|
||||
if let interactor = interactor {
|
||||
self?.reconnectWhenPossible(interactor: interactor)
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,6 +85,12 @@ class WalletConnect {
|
||||
}
|
||||
}
|
||||
|
||||
private func reconnectWhenPossible(interactor: WCInteractor) {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(10)) { [weak interactor] in
|
||||
interactor?.resume() // TODO: reconnect when appropriate.
|
||||
}
|
||||
}
|
||||
|
||||
private func approveTransaction(id: Int64, wct: WCEthereumTransaction, address: String, interactor: WCInteractor?) {
|
||||
guard let to = wct.to else {
|
||||
rejectRequest(id: id, interactor: interactor, message: "Something went wrong.")
|
||||
|
Loading…
Reference in New Issue
Block a user