Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions StikJIT/JSSupport/RunJSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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?()
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions StikJIT/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down