From 75805044a4e1ba1ef95bf348ab2e81da82ba1f1b Mon Sep 17 00:00:00 2001 From: Ivan Grachyov Date: Thu, 24 Jun 2021 23:35:57 +0300 Subject: [PATCH] Simplify windows management --- Encrypted Ink/Agent.swift | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Encrypted Ink/Agent.swift b/Encrypted Ink/Agent.swift index 6fbcdfdd..b568ebde 100644 --- a/Encrypted Ink/Agent.swift +++ b/Encrypted Ink/Agent.swift @@ -23,21 +23,15 @@ class Agent: NSObject { checkPasteboardAndOpen(onAppStart: false) } - func showInitialScreen(onAppStart: Bool, wcSession: WCSession?) { - let windowController: NSWindowController - if onAppStart, let currentWindowController = Window.current { - windowController = currentWindowController - Window.activate(windowController) - } else { - windowController = Window.showNew() - } + func showInitialScreen(wcSession: WCSession?) { + let windowController = Window.showNew() guard hasPassword else { let welcomeViewController = WelcomeViewController.new { [weak self] createdPassword in guard createdPassword else { return } self?.didEnterPasswordOnStart = true self?.hasPassword = true - self?.showInitialScreen(onAppStart: onAppStart, wcSession: wcSession) + self?.showInitialScreen(wcSession: wcSession) } windowController.contentViewController = welcomeViewController return @@ -47,7 +41,7 @@ class Agent: NSObject { askAuthentication(on: windowController.window, requireAppPasswordScreen: true, reason: "Start") { [weak self] success in if success { self?.didEnterPasswordOnStart = true - self?.showInitialScreen(onAppStart: onAppStart, wcSession: wcSession) + self?.showInitialScreen(wcSession: wcSession) } } return @@ -89,7 +83,7 @@ class Agent: NSObject { func processInputLink(_ link: String) { let session = sessionWithLink(link) - showInitialScreen(onAppStart: false, wcSession: session) + showInitialScreen(wcSession: session) } func getAccountSelectionCompletionIfShouldSelect() -> ((Account) -> Void)? { @@ -164,7 +158,7 @@ class Agent: NSObject { private func checkPasteboardAndOpen(onAppStart: Bool) { let session = getSessionFromPasteboard() - showInitialScreen(onAppStart: onAppStart, wcSession: session) + showInitialScreen(wcSession: session) } private func sessionWithLink(_ link: String) -> WCSession? {