Skip to content

Commit 16bbb3d

Browse files
committed
feat: do not open safari when change save location
If Safari is not running, do not open it, only send messages to the extension when Safari is running.
1 parent c38c3a3 commit 16bbb3d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

xcode/App-Mac/ViewController.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ class ViewController: NSViewController {
6565
// update user interface text display
6666
self.saveLocation.stringValue = url.absoluteString
6767
self.saveLocation.toolTip = url.absoluteString
68-
// notify browser extension of relevant updates
69-
sendExtensionMessage(
70-
name: "SAVE_LOCATION_CHANGED",
71-
userInfo: [
72-
"saveLocation": url.absoluteString.removingPercentEncoding ?? url.absoluteString,
73-
"returnApp": true
74-
]
75-
)
68+
// notify browser extension of relevant updates only when Safari is running
69+
if !NSRunningApplication.runningApplications(withBundleIdentifier: "com.apple.Safari").isEmpty {
70+
sendExtensionMessage(
71+
name: "SAVE_LOCATION_CHANGED",
72+
userInfo: [
73+
"saveLocation": url.absoluteString.removingPercentEncoding ?? url.absoluteString,
74+
"returnApp": true
75+
]
76+
)
77+
}
7678
})
7779
}
7880

0 commit comments

Comments
 (0)