|
|
@@ -3,14 +3,17 @@
|
|
|
// indeed_ai_job_search
|
|
|
//
|
|
|
|
|
|
+import AppKit
|
|
|
import SwiftUI
|
|
|
|
|
|
@main
|
|
|
struct indeed_ai_job_searchApp: App {
|
|
|
+ @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
|
|
|
@State private var dependencies = AppDependencies.live
|
|
|
|
|
|
var body: some Scene {
|
|
|
- WindowGroup {
|
|
|
+ // Single unique window — WindowGroup would spawn multiple instances on macOS.
|
|
|
+ Window("indeed_ai_job_search", id: "main") {
|
|
|
RootShellView(dependencies: dependencies)
|
|
|
.ignoresSafeArea()
|
|
|
.frame(minWidth: AppSpacing.minWindowWidth, minHeight: 520)
|
|
|
@@ -22,3 +25,19 @@ struct indeed_ai_job_searchApp: App {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/// Keeps exactly one running process of this app; terminates older duplicates on launch.
|
|
|
+final class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
+ func applicationWillFinishLaunching(_ notification: Notification) {
|
|
|
+ guard let bundleID = Bundle.main.bundleIdentifier else { return }
|
|
|
+ let current = NSRunningApplication.current
|
|
|
+ for app in NSRunningApplication.runningApplications(withBundleIdentifier: bundleID)
|
|
|
+ where app != current {
|
|
|
+ app.terminate()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
|
|
+ true
|
|
|
+ }
|
|
|
+}
|