From 4551f70b183dbd7edbaa788f9a3a8c67e73751b4 Mon Sep 17 00:00:00 2001 From: Ivan Grachev Date: Sun, 20 Jun 2021 20:36:06 +0300 Subject: [PATCH] Kill all sessions on app quit --- Encrypted Ink/Agent.swift | 6 +++++- Encrypted Ink/WalletConnect.swift | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Encrypted Ink/Agent.swift b/Encrypted Ink/Agent.swift index a9e3ca2f..797c2fb7 100644 --- a/Encrypted Ink/Agent.swift +++ b/Encrypted Ink/Agent.swift @@ -114,7 +114,11 @@ class Agent: NSObject { alert.addButton(withTitle: "OK") alert.addButton(withTitle: "Cancel") if alert.runModal() == .alertFirstButtonReturn { - NSApp.terminate(nil) + statusBarItem = nil + WalletConnect.shared.killAllSessions() + DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2)) { + NSApp.terminate(nil) + } } } diff --git a/Encrypted Ink/WalletConnect.swift b/Encrypted Ink/WalletConnect.swift index d1337f5c..14029f1d 100644 --- a/Encrypted Ink/WalletConnect.swift +++ b/Encrypted Ink/WalletConnect.swift @@ -28,6 +28,12 @@ class WalletConnect { interactors.append(interactor) } + func killAllSessions() { + interactors.forEach { + $0.killSession().cauterize() + } + } + private func configure(interactor: WCInteractor, address: String) { let accounts = [address] let chainId = 1