mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-14 06:26:41 +03:00
40 lines
1.3 KiB
Swift
40 lines
1.3 KiB
Swift
// Copyright © 2021 Encrypted Ink. All rights reserved.
|
|
|
|
import Cocoa
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
private let agent = Agent.shared
|
|
|
|
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
|
return false
|
|
}
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
agent.start()
|
|
agent.setupStatusBarItem()
|
|
}
|
|
|
|
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
|
agent.reopen()
|
|
return true
|
|
}
|
|
|
|
func application(_ application: NSApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([NSUserActivityRestoring]) -> Void) -> Bool {
|
|
let prefix = "https://encrypted.ink/wc?uri="
|
|
if let url = userActivity.webpageURL?.absoluteString, url.hasPrefix(prefix),
|
|
let link = url.dropFirst(prefix.count).removingPercentEncoding {
|
|
agent.processInputLink(link)
|
|
}
|
|
// TODO: do something if could not parse input link
|
|
return true
|
|
}
|
|
|
|
@IBAction func didCmdQ(_ sender: Any) {
|
|
Window.closeAll(updateStatusBarItem: false)
|
|
agent.warnBeforeQuitting(updateStatusBarAfterwards: true)
|
|
}
|
|
|
|
}
|