Skip to content
Merged
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
43 changes: 43 additions & 0 deletions StikJIT/StikJITApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ 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
@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"
Expand Down Expand Up @@ -530,6 +533,12 @@ struct HeartbeatApp: App {
LoadingView(showAlert: $show_alert, alertTitle: $alert_title, alertMessage: $alert_string)
.onAppear {
dnsChecker.checkDNS()
timeoutTimer?.invalidate()
timeoutTimer = Timer.scheduledTimer(withTimeInterval: 30, repeats: false) { _ in
if isLoading2 {
showTimeoutError = true
}
}
checkVPNConnection() { result, vpn_error in
if result {
if FileManager.default.fileExists(atPath: URL.documentsDirectory.appendingPathComponent("pairingFile.plist").path) {
Expand Down Expand Up @@ -593,6 +602,34 @@ 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",
secondaryButtonText: "View Logs",
onPrimaryButtonTap: {
isLoading2 = false
},
onSecondaryButtonTap: {
showLogs = true
},
showSecondaryButton: true
)
}
}
)
.sheet(isPresented: $showLogs, onDismiss: {
isLoading2 = false
}) {
ConsoleLogsView()
}
} else {
MainTabView()
.onAppear {
Expand Down Expand Up @@ -652,6 +689,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"
Expand Down