fix: onboarding reopen
This commit is contained in:
@@ -34,29 +34,48 @@ final class OnboardingWindowPresenter {
|
|||||||
private var isShowingWindow = false
|
private var isShowingWindow = false
|
||||||
|
|
||||||
func show(settingsManager: SettingsManager) {
|
func show(settingsManager: SettingsManager) {
|
||||||
if activateIfPresent() { return }
|
print("DEBUG: OnboardingWindowPresenter.show called")
|
||||||
guard !isShowingWindow else { return }
|
if activateIfPresent() {
|
||||||
|
print("DEBUG: Onboarding already present, activated")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
guard !isShowingWindow else {
|
||||||
|
print("DEBUG: Onboarding already showing")
|
||||||
|
return
|
||||||
|
}
|
||||||
isShowingWindow = true
|
isShowingWindow = true
|
||||||
|
print("DEBUG: Creating new onboarding window")
|
||||||
createWindow(settingsManager: settingsManager)
|
createWindow(settingsManager: settingsManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
func activateIfPresent() -> Bool {
|
func activateIfPresent() -> Bool {
|
||||||
guard let window = windowController?.window, window.isVisible else {
|
guard let window = windowController?.window else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
NSApp.unhide(nil)
|
// Even if not visible, we may still need to activate it if it exists
|
||||||
NSApp.activate(ignoringOtherApps: true)
|
let needsActivation = !window.isVisible || window.isMiniaturized
|
||||||
|
|
||||||
if window.isMiniaturized {
|
if needsActivation {
|
||||||
window.deminiaturize(nil)
|
NSApp.unhide(nil)
|
||||||
|
NSApp.activate(ignoringOtherApps: true)
|
||||||
|
|
||||||
|
if window.isMiniaturized {
|
||||||
|
window.deminiaturize(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the window is properly ordered front
|
||||||
|
window.makeKeyAndOrderFront(nil)
|
||||||
|
window.orderFrontRegardless()
|
||||||
|
|
||||||
|
// Make sure it's in the main space
|
||||||
|
window.makeMain()
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
window.makeKeyAndOrderFront(nil)
|
return false
|
||||||
window.orderFrontRegardless()
|
|
||||||
window.makeMain()
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func close() {
|
func close() {
|
||||||
|
|||||||
Reference in New Issue
Block a user