8000 Fix SwiftUI window management issue with an ugly hack 🤮 · codeface-io/Codeface@9993c83 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9993c83

Browse files
committed
Fix SwiftUI window management issue with an ugly hack 🤮
1 parent 53b6b82 commit 9993c83

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

‎Code/App/CodefaceApp.swift

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ struct CodefaceApp: App
2727

2828
Task
2929
{
30+
// FIXME: this waiting is an ugly workaround. without it it's too early to read the windows. NSApp.windows would still be empty because windows from last session would not have been restored yet
31+
try await Task.sleep(for: .milliseconds(100))
3032
Self.openDocumentWindowIfNoneIsOpen()
3133
}
3234
}
@@ -187,18 +189,8 @@ struct CodefaceApp: App
187189

188190
private static func moreWindowsThanTestingDashboardAreOpen() -> Bool
189191
{
190-
if NSApp.windows.count > 1
191-
{
192-
return true
193-
}
194-
195-
if NSApp.window(forID: TestingDashboardWindow.id) != nil
196-
{
197-
return false
198-
}
199-
200-
print(NSApp.windows.count)
201-
192+
if NSApp.windows.count > 1 { return true }
193+
if NSApp.window(forID: TestingDashboardWindow.id) != nil { return false }
202194
return NSApp.windows.count == 1
203195
}
204196

0 commit comments

Comments
 (0)
0