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
9 changes: 9 additions & 0 deletions StikJIT/JSSupport/RunJSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class RunJSViewModel: ObservableObject {
var pid: Int
var debugProxy: OpaquePointer?
var semaphore: dispatch_semaphore_t?
var status: Bool = false

init(pid: Int, debugProxy: OpaquePointer?, semaphore: dispatch_semaphore_t?) {
self.pid = pid
Expand Down Expand Up @@ -77,12 +78,14 @@ class RunJSViewModel: ObservableObject {

self.logs.append("Script Execution Completed")
self.logs.append("You are safe to close the PIP Window.")
self.status = true
}
}
}

struct RunJSViewPiP: View {
@Binding var model: RunJSViewModel?
@Binding var isProcessing: Bool
@State var logs: [String] = []
let timer = Timer.publish(every: 0.034, on: .main, in: .common).autoconnect()

Expand All @@ -98,6 +101,12 @@ struct RunJSViewPiP: View {
.padding()
.onReceive(timer) { _ in
self.logs = model?.logs ?? []
if let status = model?.status {
if status {
isProcessing = false
model = nil
}
}
}
.frame(width: 300, height: 150)
}
Expand Down
4 changes: 3 additions & 1 deletion StikJIT/Views/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct HomeView: View {
@State private var showingConsoleLogsView = false
@State private var importProgress: Float = 0.0


@State private var pidTextAlertShow = false
@State private var pidStr = ""

Expand Down Expand Up @@ -307,7 +308,8 @@ struct HomeView: View {
get: { useDefaultScript && isProcessing },
set: { newValue in isProcessing = newValue }
)) {
RunJSViewPiP(model: $jsModel)
RunJSViewPiP(model: $jsModel,isProcessing: $isProcessing)

}
.sheet(isPresented: $scriptViewShow) {
NavigationView {
Expand Down