Skip to content

Open source CapCut alternative.

TypeScript

fix(app): render notch overlay when permission window is closed via X

David Le8a0febf5af06
diff --git a/apps/Donkey/Sources/Donkey/MacPermissionSetupWindowController.swift b/apps/Donkey/Sources/Donkey/MacPermissionSetupWindowController.swift
index 43502dc2..3a68084a 100644
--- a/apps/Donkey/Sources/Donkey/MacPermissionSetupWindowController.swift
+++ b/apps/Donkey/Sources/Donkey/MacPermissionSetupWindowController.swift
@@ -6,10 +6,11 @@ import DonkeyRuntime
import SwiftUI
@MainActor
-final class MacPermissionSetupWindowController: NSWindowController {
+final class MacPermissionSetupWindowController: NSWindowController, NSWindowDelegate {
var completed: (() -> Void)?
private let model: MacPermissionSetupModel
+ private var didComplete = false
init(model: MacPermissionSetupModel = MacPermissionSetupModel()) {
self.model = model
@@ -21,10 +22,13 @@ final class MacPermissionSetupWindowController: NSWindowController {
window.setContentSize(NSSize(width: 640, height: 600))
window.isReleasedWhenClosed = false
super.init(window: window)
+ window.delegate = self
+ // Continue/Skip just closes the window. Closing — whether from those buttons or the X — is the
+ // single place that fires `completed`, so the overlay (notch) starts up regardless of how the
+ // user dismisses this window.
model.completed = { [weak self] in
self?.close()
- self?.completed?()
}
}
@@ -32,6 +36,12 @@ final class MacPermissionSetupWindowController: NSWindowController {
nil
}
+ func windowWillClose(_ notification: Notification) {
+ guard !didComplete else { return }
+ didComplete = true
+ completed?()
+ }
+
var permissionsAreReady: Bool {
model.refresh()
return model.canContinue