From 195a2e5c1ce673e99b3124850bb0211c7570827e Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Wed, 23 Jul 2025 13:44:06 -0400 Subject: [PATCH 1/6] Add timeout error and log viewer --- StikJIT/StikJITApp.swift | 33 ++++++++++++++++++++++++++++++++ StikJIT/Views/LogFileView.swift | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 StikJIT/Views/LogFileView.swift diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index 43aa666e..a10de4dc 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -452,6 +452,8 @@ struct HeartbeatApp: App { @State private var show_alert = false @State private var alert_string = "" @State private var alert_title = "" + @State private var showTimeoutError = false + @State private var showLogs = false @StateObject private var mount = MountingProgress.shared @StateObject private var dnsChecker = DNSChecker() // New DNS check state object @AppStorage("appTheme") private var appTheme: String = "system" @@ -530,6 +532,11 @@ struct HeartbeatApp: App { LoadingView(showAlert: $show_alert, alertTitle: $alert_title, alertMessage: $alert_string) .onAppear { dnsChecker.checkDNS() + DispatchQueue.main.asyncAfter(deadline: .now() + 30) { + if isLoading2 { + showTimeoutError = true + } + } checkVPNConnection() { result, vpn_error in if result { if FileManager.default.fileExists(atPath: URL.documentsDirectory.appendingPathComponent("pairingFile.plist").path) { @@ -593,6 +600,32 @@ struct HeartbeatApp: App { print("Failed") } } + .overlay( + ZStack { + if showTimeoutError { + CustomErrorView( + title: "Connection Error", + message: "Check your connection and ensure your pairing file is valid and try again.", + onDismiss: { + showTimeoutError = false + }, + showButton: true, + primaryButtonText: "Continue Anyway", + onPrimaryButtonTap: { + isLoading2 = false + }, + showSecondaryButton: true, + secondaryButtonText: "View Logs", + onSecondaryButtonTap: { + showLogs = true + } + ) + } + } + ) + .sheet(isPresented: $showLogs) { + LogFileView() + } } else { MainTabView() .onAppear { diff --git a/StikJIT/Views/LogFileView.swift b/StikJIT/Views/LogFileView.swift new file mode 100644 index 00000000..1922de22 --- /dev/null +++ b/StikJIT/Views/LogFileView.swift @@ -0,0 +1,34 @@ +import SwiftUI + +struct LogFileView: View { + @Environment(\.dismiss) private var dismiss + @State private var logText: String = "" + + var body: some View { + NavigationView { + ScrollView { + Text(logText) + .font(.system(.body, design: .monospaced)) + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } + .navigationTitle("idevice_log.txt") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button("Done") { dismiss() } + } + } + } + .onAppear(perform: loadLog) + } + + private func loadLog() { + let logPath = URL.documentsDirectory.appendingPathComponent("idevice_log.txt") + if let content = try? String(contentsOf: logPath) { + logText = content + } else { + logText = "Log file not found." + } + } +} From b96055f60e3e1beec8691d01f08a5f5bd3c801d0 Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Wed, 23 Jul 2025 13:47:53 -0400 Subject: [PATCH 2/6] Fix parameter order in timeout alert --- StikJIT/StikJITApp.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index a10de4dc..a4538453 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -611,14 +611,14 @@ struct HeartbeatApp: App { }, showButton: true, primaryButtonText: "Continue Anyway", + secondaryButtonText: "View Logs", onPrimaryButtonTap: { isLoading2 = false }, - showSecondaryButton: true, - secondaryButtonText: "View Logs", onSecondaryButtonTap: { showLogs = true - } + }, + showSecondaryButton: true ) } } From 9e2fd8c23650aa4c756260671bae9adccf0cd1ec Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:01:10 -0400 Subject: [PATCH 3/6] Add timeout timer for loading --- StikJIT/StikJITApp.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index a4538453..e4fc710f 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -454,6 +454,7 @@ struct HeartbeatApp: App { @State private var alert_title = "" @State private var showTimeoutError = false @State private var showLogs = false + @State private var timeoutTimer: Timer? @StateObject private var mount = MountingProgress.shared @StateObject private var dnsChecker = DNSChecker() // New DNS check state object @AppStorage("appTheme") private var appTheme: String = "system" @@ -532,7 +533,8 @@ struct HeartbeatApp: App { LoadingView(showAlert: $show_alert, alertTitle: $alert_title, alertMessage: $alert_string) .onAppear { dnsChecker.checkDNS() - DispatchQueue.main.asyncAfter(deadline: .now() + 30) { + timeoutTimer?.invalidate() + timeoutTimer = Timer.scheduledTimer(withTimeInterval: 30, repeats: false) { _ in if isLoading2 { showTimeoutError = true } @@ -685,6 +687,12 @@ struct HeartbeatApp: App { startHeartbeatInBackground() } } + .onChange(of: isLoading2) { newValue in + if !newValue { + timeoutTimer?.invalidate() + timeoutTimer = nil + } + } .onChange(of: dnsChecker.dnsError) { newError in if let errorMsg = newError, !errorMsg.contains("Not connected to WiFi") { alert_title = "Network Issue" From abd989f00fb27af78f3534312e30fa2a8dde16bc Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:12:32 -0400 Subject: [PATCH 4/6] Update timeout actions and log view --- StikJIT/StikJITApp.swift | 1 + StikJIT/Views/LogFileView.swift | 27 ++++++++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index e4fc710f..939feabd 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -618,6 +618,7 @@ struct HeartbeatApp: App { isLoading2 = false }, onSecondaryButtonTap: { + isLoading2 = false showLogs = true }, showSecondaryButton: true diff --git a/StikJIT/Views/LogFileView.swift b/StikJIT/Views/LogFileView.swift index 1922de22..80108891 100644 --- a/StikJIT/Views/LogFileView.swift +++ b/StikJIT/Views/LogFileView.swift @@ -2,21 +2,38 @@ import SwiftUI struct LogFileView: View { @Environment(\.dismiss) private var dismiss + @Environment(\.colorScheme) private var colorScheme + @AppStorage("customAccentColor") private var customAccentColorHex: String = "" @State private var logText: String = "" + private var accentColor: Color { + if customAccentColorHex.isEmpty { + return .blue + } else { + return Color(hex: customAccentColorHex) ?? .blue + } + } + var body: some View { NavigationView { - ScrollView { - Text(logText) - .font(.system(.body, design: .monospaced)) - .frame(maxWidth: .infinity, alignment: .leading) - .padding() + ZStack { + Color(colorScheme == .dark ? .black : .white) + .edgesIgnoringSafeArea(.all) + + ScrollView { + Text(logText) + .font(.system(.body, design: .monospaced)) + .foregroundColor(colorScheme == .dark ? .white : .black) + .frame(maxWidth: .infinity, alignment: .leading) + .padding() + } } .navigationTitle("idevice_log.txt") .navigationBarTitleDisplayMode(.inline) .toolbar { ToolbarItem(placement: .navigationBarTrailing) { Button("Done") { dismiss() } + .foregroundColor(accentColor) } } } From 86b068b3e6213e25ff4b0e228a5c22c81e754ab3 Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Wed, 23 Jul 2025 14:19:09 -0400 Subject: [PATCH 5/6] Open ConsoleLogsView from timeout alert --- StikJIT/StikJITApp.swift | 2 +- StikJIT/Views/LogFileView.swift | 51 --------------------------------- 2 files changed, 1 insertion(+), 52 deletions(-) delete mode 100644 StikJIT/Views/LogFileView.swift diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index 939feabd..ac53b98d 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -627,7 +627,7 @@ struct HeartbeatApp: App { } ) .sheet(isPresented: $showLogs) { - LogFileView() + ConsoleLogsView() } } else { MainTabView() diff --git a/StikJIT/Views/LogFileView.swift b/StikJIT/Views/LogFileView.swift deleted file mode 100644 index 80108891..00000000 --- a/StikJIT/Views/LogFileView.swift +++ /dev/null @@ -1,51 +0,0 @@ -import SwiftUI - -struct LogFileView: View { - @Environment(\.dismiss) private var dismiss - @Environment(\.colorScheme) private var colorScheme - @AppStorage("customAccentColor") private var customAccentColorHex: String = "" - @State private var logText: String = "" - - private var accentColor: Color { - if customAccentColorHex.isEmpty { - return .blue - } else { - return Color(hex: customAccentColorHex) ?? .blue - } - } - - var body: some View { - NavigationView { - ZStack { - Color(colorScheme == .dark ? .black : .white) - .edgesIgnoringSafeArea(.all) - - ScrollView { - Text(logText) - .font(.system(.body, design: .monospaced)) - .foregroundColor(colorScheme == .dark ? .white : .black) - .frame(maxWidth: .infinity, alignment: .leading) - .padding() - } - } - .navigationTitle("idevice_log.txt") - .navigationBarTitleDisplayMode(.inline) - .toolbar { - ToolbarItem(placement: .navigationBarTrailing) { - Button("Done") { dismiss() } - .foregroundColor(accentColor) - } - } - } - .onAppear(perform: loadLog) - } - - private func loadLog() { - let logPath = URL.documentsDirectory.appendingPathComponent("idevice_log.txt") - if let content = try? String(contentsOf: logPath) { - logText = content - } else { - logText = "Log file not found." - } - } -} From 18f4f15554ddcb6031bd9e4e8be4bfaca1bd36d5 Mon Sep 17 00:00:00 2001 From: Stephen B <158498287+StephenDev0@users.noreply.github.com> Date: Wed, 23 Jul 2025 17:06:51 -0400 Subject: [PATCH 6/6] Open logs without dismissing loading --- StikJIT/StikJITApp.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/StikJIT/StikJITApp.swift b/StikJIT/StikJITApp.swift index ac53b98d..5df6a982 100644 --- a/StikJIT/StikJITApp.swift +++ b/StikJIT/StikJITApp.swift @@ -618,7 +618,6 @@ struct HeartbeatApp: App { isLoading2 = false }, onSecondaryButtonTap: { - isLoading2 = false showLogs = true }, showSecondaryButton: true @@ -626,7 +625,9 @@ struct HeartbeatApp: App { } } ) - .sheet(isPresented: $showLogs) { + .sheet(isPresented: $showLogs, onDismiss: { + isLoading2 = false + }) { ConsoleLogsView() } } else {