diff --git a/PayfritWorks/Services/APIService.swift b/PayfritWorks/Services/APIService.swift index 8ac3a07..1e7ca02 100644 --- a/PayfritWorks/Services/APIService.swift +++ b/PayfritWorks/Services/APIService.swift @@ -691,14 +691,14 @@ actor APIService { func getAvatarUrl() async throws -> String? { let json = try await getJSON("/auth/avatar.php") - print("[Avatar] Response: \(json)") + if IS_DEV { print("[Avatar] Response: \(json)") } guard ok(json) else { - print("[Avatar] Response not OK") + if IS_DEV { print("[Avatar] Response not OK") } return nil } let data = json["DATA"] as? [String: Any] ?? json - print("[Avatar] Data: \(data)") + if IS_DEV { print("[Avatar] Data: \(data)") } // Try all possible key variations for avatar URL let keys = ["AVATAR_URL", "AVATARURL", "AvatarUrl", "avatarUrl", "avatar_url", @@ -707,16 +707,16 @@ actor APIService { for key in keys { if let url = data[key] as? String, !url.isEmpty { let resolved = Self.resolvePhotoUrl(url) - print("[Avatar] Found key '\(key)' with value: \(url) -> \(resolved)") + if IS_DEV { print("[Avatar] Found key '\(key)' with value: \(url) -> \(resolved)") } return resolved } if let url = json[key] as? String, !url.isEmpty { let resolved = Self.resolvePhotoUrl(url) - print("[Avatar] Found key '\(key)' in json with value: \(url) -> \(resolved)") + if IS_DEV { print("[Avatar] Found key '\(key)' in json with value: \(url) -> \(resolved)") } return resolved } } - print("[Avatar] No avatar URL found in response") + if IS_DEV { print("[Avatar] No avatar URL found in response") } return nil } @@ -724,7 +724,7 @@ actor APIService { func getUserAvatarUrl(userId: Int) async throws -> String? { // Try the avatar endpoint with UserID let json = try await postJSON("/auth/avatar.php", payload: ["UserID": userId]) - print("[Avatar] getUserAvatarUrl(\(userId)) Response: \(json)") + if IS_DEV { print("[Avatar] getUserAvatarUrl(\(userId)) Response: \(json)") } let data = json["DATA"] as? [String: Any] ?? json @@ -733,15 +733,15 @@ actor APIService { "UserPhotoUrl", "USERPHOTOURL", "userPhotoUrl"] for key in keys { if let url = data[key] as? String, !url.isEmpty { - print("[Avatar] Found avatar for userId \(userId): \(url)") + if IS_DEV { print("[Avatar] Found avatar for userId \(userId): \(url)") } return Self.resolvePhotoUrl(url) } if let url = json[key] as? String, !url.isEmpty { - print("[Avatar] Found avatar for userId \(userId): \(url)") + if IS_DEV { print("[Avatar] Found avatar for userId \(userId): \(url)") } return Self.resolvePhotoUrl(url) } } - print("[Avatar] No avatar found for userId \(userId), all keys: \(json.keys.sorted())") + if IS_DEV { print("[Avatar] No avatar found for userId \(userId), all keys: \(json.keys.sorted())") } return nil } diff --git a/PayfritWorks/Services/BeaconScanner.swift b/PayfritWorks/Services/BeaconScanner.swift index 8679784..ab8447b 100644 --- a/PayfritWorks/Services/BeaconScanner.swift +++ b/PayfritWorks/Services/BeaconScanner.swift @@ -89,7 +89,7 @@ final class BeaconScanner: NSObject, ObservableObject { } } - print("[BeaconScanner] Started scanning for \(BeaconShardPool.uuids.count) shard UUIDs, target ServicePointId: \(targetServicePointId)") + if IS_DEV { print("[BeaconScanner] Started scanning for \(BeaconShardPool.uuids.count) shard UUIDs, target ServicePointId: \(targetServicePointId)") } } func stopScanning() { @@ -137,12 +137,12 @@ final class BeaconScanner: NSObject, ObservableObject { await MainActor.run { self.resolvedBeacons[key] = servicePointId self.pendingResolutions.remove(key) - print("[BeaconScanner] Resolved \(key) -> ServicePointId \(servicePointId)") + if IS_DEV { print("[BeaconScanner] Resolved \(key) -> ServicePointId \(servicePointId)") } } } catch { await MainActor.run { self.pendingResolutions.remove(key) - print("[BeaconScanner] Failed to resolve \(key): \(error)") + if IS_DEV { print("[BeaconScanner] Failed to resolve \(key): \(error)") } } } } @@ -181,7 +181,7 @@ extension BeaconScanner: CLLocationManagerDelegate { if rssiSamples.count >= minSamplesToConfirm { let avg = Double(rssiSamples.reduce(0, +)) / Double(rssiSamples.count) - print("[BeaconScanner] Target beacon confirmed! Avg RSSI: \(avg)") + if IS_DEV { print("[BeaconScanner] Target beacon confirmed! Avg RSSI: \(avg)") } DispatchQueue.main.async { [weak self] in self?.onBeaconDetected(avg) } @@ -210,6 +210,6 @@ extension BeaconScanner: CLLocationManagerDelegate { } func locationManager(_ manager: CLLocationManager, didFailRangingFor constraint: CLBeaconIdentityConstraint, error: Error) { - print("[BeaconScanner] Ranging failed: \(error)") + if IS_DEV { print("[BeaconScanner] Ranging failed: \(error)") } } } diff --git a/PayfritWorks/Views/AboutScreen.swift b/PayfritWorks/Views/AboutScreen.swift index 49b402e..04e3146 100644 --- a/PayfritWorks/Views/AboutScreen.swift +++ b/PayfritWorks/Views/AboutScreen.swift @@ -128,7 +128,7 @@ struct AboutScreen: View { aboutInfo = try await APIService.shared.getAboutInfo() } catch { // Use fallback on error - print("Failed to load about info: \(error)") + if IS_DEV { print("Failed to load about info: \(error)") } } isLoading = false } diff --git a/PayfritWorks/Views/TaskDetailScreen.swift b/PayfritWorks/Views/TaskDetailScreen.swift index 89ab296..ced1ead 100644 --- a/PayfritWorks/Views/TaskDetailScreen.swift +++ b/PayfritWorks/Views/TaskDetailScreen.swift @@ -710,12 +710,12 @@ struct TaskDetailScreen: View { } } - print("[Beacon] showCompleteButton=\(showCompleteButton), servicePointId=\(d.servicePointId)") + if IS_DEV { print("[Beacon] showCompleteButton=\(showCompleteButton), servicePointId=\(d.servicePointId)") } if showCompleteButton && d.servicePointId > 0 { - print("[Beacon] Starting beacon scanning for ServicePointId: \(d.servicePointId)") + if IS_DEV { print("[Beacon] Starting beacon scanning for ServicePointId: \(d.servicePointId)") } startBeaconScanning(d.servicePointId) } else { - print("[Beacon] NOT starting scan - showCompleteButton=\(showCompleteButton), servicePointId=\(d.servicePointId)") + if IS_DEV { print("[Beacon] NOT starting scan - showCompleteButton=\(showCompleteButton), servicePointId=\(d.servicePointId)") } } } catch { self.error = error.localizedDescription