@@ -100,18 +100,22 @@ extension AppDelegate {
100100
101101 // MARK: - Window Identification
102102
103+ private enum WindowId {
104+ static let main = " main "
105+ static let welcome = " welcome "
106+ static let connectionForm = " connection-form "
107+ }
108+
103109 func isMainWindow( _ window: NSWindow ) -> Bool {
104- guard let identifier = window. identifier? . rawValue else { return false }
105- return identifier. contains ( " main " )
110+ window. identifier? . rawValue == WindowId . main
106111 }
107112
108113 func isWelcomeWindow( _ window: NSWindow ) -> Bool {
109- window. identifier? . rawValue == " welcome " ||
110- window. title. lowercased ( ) . contains ( " welcome " )
114+ window. identifier? . rawValue == WindowId . welcome
111115 }
112116
113117 private func isConnectionFormWindow( _ window: NSWindow ) -> Bool {
114- window. identifier? . rawValue. contains ( " connection-form " ) == true
118+ window. identifier? . rawValue == WindowId . connectionForm
115119 }
116120
117121 // MARK: - Welcome Window
@@ -259,10 +263,7 @@ extension AppDelegate {
259263
260264 if remainingMainWindows == 0 {
261265 NotificationCenter . default. post ( name: . mainWindowWillClose, object: nil )
262-
263- DispatchQueue . main. async {
264- self . openWelcomeWindow ( )
265- }
266+ openWelcomeWindow ( )
266267 }
267268 }
268269 }
@@ -273,13 +274,9 @@ extension AppDelegate {
273274
274275 if isWelcomeWindow ( window) ,
275276 window. occlusionState. contains ( . visible) ,
276- NSApp . windows. contains ( where: { isMainWindow ( $0) && $0. isVisible } ) {
277- DispatchQueue . main. async { [ weak self] in
278- guard let self else { return }
279- if self . isWelcomeWindow ( window) , window. isVisible {
280- window. close ( )
281- }
282- }
277+ NSApp . windows. contains ( where: { isMainWindow ( $0) && $0. isVisible } ) ,
278+ window. isVisible {
279+ window. close ( )
283280 }
284281 }
285282
0 commit comments