Skip to content

Commit aa92ef4

Browse files
committed
Fix script bug
1 parent f4dc4d8 commit aa92ef4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

StikJIT/Views/HomeView.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ struct HomeView: View {
255255
var autoScriptData: Data? = nil
256256
var autoScriptName: String? = nil
257257

258-
if let scriptInfo = autoScript(for: selectedBundle) {
258+
if !hasAssignedScript(for: selectedBundle),
259+
let scriptInfo = autoScript(for: selectedBundle) {
259260
autoScriptData = scriptInfo.data
260261
autoScriptName = scriptInfo.name
261262
}
@@ -313,6 +314,7 @@ struct HomeView: View {
313314
config.scriptName = scriptName
314315
}
315316
if config.scriptData == nil, let bundleID = config.bundleID,
317+
!hasAssignedScript(for: bundleID),
316318
let scriptInfo = autoScript(for: bundleID) {
317319
config.scriptData = scriptInfo.data
318320
config.scriptName = scriptInfo.name
@@ -1260,6 +1262,16 @@ struct HomeView: View {
12601262
}
12611263
private func refreshBackground() { }
12621264

1265+
private func hasAssignedScript(for bundleID: String) -> Bool {
1266+
guard enableAdvancedOptions else { return false }
1267+
guard let mapping = UserDefaults.standard.dictionary(forKey: "BundleScriptMap") as? [String: String],
1268+
let scriptName = mapping[bundleID] else { return false }
1269+
let scriptsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
1270+
.appendingPathComponent("scripts")
1271+
let scriptURL = scriptsDirectory.appendingPathComponent(scriptName)
1272+
return FileManager.default.fileExists(atPath: scriptURL.path)
1273+
}
1274+
12631275
private func autoScript(for bundleID: String) -> (data: Data, name: String)? {
12641276
guard ProcessInfo.processInfo.hasTXM else { return nil }
12651277
guard #available(iOS 26, *) else { return nil }

0 commit comments

Comments
 (0)