Add menu item for enabling Safari extension. Remove WC instructions

This commit is contained in:
Ivan Grachyov 2021-11-29 22:24:05 +03:00
parent 5c1e918009
commit 9e13e2186e
4 changed files with 7 additions and 17 deletions

View File

@ -2,6 +2,7 @@
import Cocoa
import WalletConnect
import SafariServices
import LocalAuthentication
class Agent: NSObject {
@ -134,7 +135,7 @@ class Agent: NSObject {
let menu = NSMenu(title: Strings.encryptedInk)
let showItem = NSMenuItem(title: Strings.showEncryptedInk, action: #selector(didSelectShowMenuItem), keyEquivalent: "")
let howToItem = NSMenuItem(title: Strings.howToWalletConnect, action: #selector(showInstructionsAlert), keyEquivalent: "")
let safariItem = NSMenuItem(title: Strings.enableSafariExtension, action: #selector(enableSafariExtension), keyEquivalent: "")
let mailItem = NSMenuItem(title: Strings.dropUsALine, action: #selector(didSelectMailMenuItem), keyEquivalent: "")
let githubItem = NSMenuItem(title: Strings.viewOnGithub, action: #selector(didSelectGitHubMenuItem), keyEquivalent: "")
let twitterItem = NSMenuItem(title: Strings.viewOnTwitter, action: #selector(didSelectTwitterMenuItem), keyEquivalent: "")
@ -142,7 +143,7 @@ class Agent: NSObject {
showItem.attributedTitle = NSAttributedString(string: "👀 " + Strings.showEncryptedInk, attributes: [.font: NSFont.systemFont(ofSize: 15, weight: .semibold)])
showItem.target = self
howToItem.target = self
safariItem.target = self
githubItem.target = self
twitterItem.target = self
mailItem.target = self
@ -151,7 +152,7 @@ class Agent: NSObject {
menu.delegate = self
menu.addItem(showItem)
menu.addItem(NSMenuItem.separator())
menu.addItem(howToItem)
menu.addItem(safariItem)
menu.addItem(NSMenuItem.separator())
menu.addItem(twitterItem)
menu.addItem(githubItem)
@ -189,9 +190,8 @@ class Agent: NSObject {
}
}
@objc private func showInstructionsAlert() {
Window.activateWindow(nil)
Alert.showWalletConnectInstructions()
@objc private func enableSafariExtension() {
SFSafariApplication.showPreferencesForExtension(withIdentifier: "ink.encrypted.macos.Safari")
}
@objc private func didSelectMailMenuItem() {

View File

@ -85,8 +85,6 @@ class AccountsListViewController: NSViewController {
menu.addItem(.separator())
menu.addItem(NSMenuItem(title: Strings.showAccountKey, action: #selector(didClickExportAccount(_:)), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: Strings.removeAccount, action: #selector(didClickRemoveAccount(_:)), keyEquivalent: ""))
menu.addItem(.separator())
menu.addItem(NSMenuItem(title: Strings.howToWalletConnect, action: #selector(showInstructionsAlert), keyEquivalent: ""))
tableView.menu = menu
}
@ -280,10 +278,6 @@ class AccountsListViewController: NSViewController {
}
}
@objc private func showInstructionsAlert() {
Alert.showWalletConnectInstructions()
}
private func removeAccountAtIndex(_ index: Int) {
let wallet = wallets[index]
try? walletsManager.delete(wallet: wallet)

View File

@ -19,7 +19,7 @@ struct Strings {
static let quit = "Quit"
static let quitEncryptedInk = "Quit Encrypted Ink?"
static let youWontBeAbleToSignRequests = "You won't be able to sign requests."
static let howToWalletConnect = "How to WalletConnect?"
static let enableSafariExtension = "Enable Safari extension…"
static let dropUsALine = "Drop us a line…"
static let viewOnGithub = "View on GitHub…"
static let viewOnTwitter = "View on Twitter…"

View File

@ -12,10 +12,6 @@ class Alert: NSAlert {
return super.runModal()
}
static func showWalletConnectInstructions() {
Alert.showWithMessage("1 — Open dapp website\n\n2 — Click “Copy to clipboard”\nunder WalletConnect QR code\n\n3 — Open Encrypted Ink", style: .informational)
}
static func showWithMessage(_ message: String, style: NSAlert.Style) {
let alert = Alert()
alert.messageText = message