diff --git a/StikJIT/JSSupport/RunJSView.swift b/StikJIT/JSSupport/RunJSView.swift index 4b1d11fa..3b883d8a 100644 --- a/StikJIT/JSSupport/RunJSView.swift +++ b/StikJIT/JSSupport/RunJSView.swift @@ -23,7 +23,7 @@ class RunJSViewModel: ObservableObject { self.semaphore = semaphore } - func runScript(path: URL) throws { + func runScript(path: URL, completion: (() -> Void)? = nil) throws { let scriptContent = try String(contentsOf: path, encoding: .utf8) scriptName = path.lastPathComponent @@ -74,9 +74,10 @@ class RunJSViewModel: ObservableObject { if let exception = self.context?.exception { self.logs.append(exception.debugDescription) } - + self.logs.append("Script Execution Completed") self.logs.append("You are safe to close the PIP Window.") + completion?() } } } diff --git a/StikJIT/Views/HomeView.swift b/StikJIT/Views/HomeView.swift index 03ed864f..96fc324e 100644 --- a/StikJIT/Views/HomeView.swift +++ b/StikJIT/Views/HomeView.swift @@ -424,8 +424,9 @@ struct HomeView: View { scriptViewShow = true DispatchQueue.global(qos: .background).async { do { - try jsModel?.runScript(path: selectedScriptURL) - isProcessing = false + try jsModel?.runScript(path: selectedScriptURL) { + isProcessing = false + } } catch { showAlert(title: "Error Occurred While Executing the Default Script.".localized, message: error.localizedDescription, showOk: true) }