Skip to content

Commit 8874be0

Browse files
committed
Use Async Dialog, Reduce Window Wait Time
Uses an async version of `NSPanel`'s `runModal` method to call the `onDialogPresented` at the same time as the modal's appearance. Prevents a bug where the welcome window cannot be dismissed in that callback.
1 parent 28848ff commit 8874be0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Sources/WelcomeWindow/Model/NSDocumentController+Extensions.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ extension NSDocumentController {
190190
panel.directoryURL = configuration.directoryURL
191191
panel.level = .modalPanel
192192

193-
DispatchQueue.main.async { onDialogPresented() }
193+
panel.begin { result in
194+
guard result == .OK, let selectedURL = panel.url else {
195+
onCancel()
196+
return
197+
}
194198

195-
let result = panel.runModal()
196-
guard result == .OK, let selectedURL = panel.url else {
197-
onCancel()
198-
return
199+
self.openDocument(at: selectedURL, onCompletion: onCompletion, onError: { _ in onCancel() })
199200
}
200-
201-
self.openDocument(at: selectedURL, onCompletion: onCompletion, onError: { _ in onCancel() })
201+
onDialogPresented()
202202
}
203203

204204
/// Opens a document at the specified URL and optionally tracks it in recent projects.

0 commit comments

Comments
 (0)