Skip to content

Commit ae8017a

Browse files
committed
Prevent opening multiple onboarding windows on reauthenticate
1 parent d2603ef commit ae8017a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

AirMessage/AppDelegate.swift

-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
182182
@objc private func onReauthenticate() {
183183
resetServer()
184184
OnboardingViewController.open()
185-
NSApp.activate(ignoringOtherApps: true)
186185
}
187186

188187
@objc private func onOpenClientList() {

AirMessage/Controllers/OnboardingViewController.swift

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,22 @@ import Foundation
99
import AppKit
1010

1111
class OnboardingViewController: NSViewController {
12-
//Keep in memory on older versions of OS X
12+
//Keep in memory for older versions of OS X
1313
private static var onboardingWindowController: NSWindowController!
1414

1515
static func open() {
16+
//If we're already showing the window, just focus it
17+
if let window = onboardingWindowController?.window, window.isVisible {
18+
window.makeKeyAndOrderFront(self)
19+
NSApp.activate(ignoringOtherApps: true)
20+
return
21+
}
22+
1623
let storyboard = NSStoryboard(name: "Main", bundle: nil)
1724
let windowController = storyboard.instantiateController(withIdentifier: "Onboarding") as! NSWindowController
1825
windowController.showWindow(nil)
1926
onboardingWindowController = windowController
27+
NSApp.activate(ignoringOtherApps: true)
2028
}
2129

2230
override func viewWillAppear() {

0 commit comments

Comments
 (0)