From 16bbb3d9c33877688223cacc8ae4333b265608f0 Mon Sep 17 00:00:00 2001 From: ACTCD <101378590+ACTCD@users.noreply.github.com> Date: Sat, 28 Sep 2024 13:21:05 +0800 Subject: [PATCH] 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. --- xcode/App-Mac/ViewController.swift | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/xcode/App-Mac/ViewController.swift b/xcode/App-Mac/ViewController.swift index fc7598ee..bf6a4267 100644 --- a/xcode/App-Mac/ViewController.swift +++ b/xcode/App-Mac/ViewController.swift @@ -65,14 +65,16 @@ class ViewController: NSViewController { // update user interface text display self.saveLocation.stringValue = url.absoluteString self.saveLocation.toolTip = url.absoluteString - // notify browser extension of relevant updates - sendExtensionMessage( - name: "SAVE_LOCATION_CHANGED", - userInfo: [ - "saveLocation": url.absoluteString.removingPercentEncoding ?? url.absoluteString, - "returnApp": true - ] - ) + // notify browser extension of relevant updates only when Safari is running + if !NSRunningApplication.runningApplications(withBundleIdentifier: "com.apple.Safari").isEmpty { + sendExtensionMessage( + name: "SAVE_LOCATION_CHANGED", + userInfo: [ + "saveLocation": url.absoluteString.removingPercentEncoding ?? url.absoluteString, + "returnApp": true + ] + ) + } }) }