fix: gate debug print() statements behind IS_DEV flag
Wrapped all debug print() calls in APIService (avatar debugging), BeaconScanner (scan/resolve logging), TaskDetailScreen (beacon state), and AboutScreen (error logging) with IS_DEV checks so they are silent in production builds. Preview-only prints in RatingDialog left as-is. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
54923ba341
commit
d5d1c35b55
4 changed files with 19 additions and 19 deletions
|
|
@ -691,14 +691,14 @@ actor APIService {
|
||||||
|
|
||||||
func getAvatarUrl() async throws -> String? {
|
func getAvatarUrl() async throws -> String? {
|
||||||
let json = try await getJSON("/auth/avatar.php")
|
let json = try await getJSON("/auth/avatar.php")
|
||||||
print("[Avatar] Response: \(json)")
|
if IS_DEV { print("[Avatar] Response: \(json)") }
|
||||||
guard ok(json) else {
|
guard ok(json) else {
|
||||||
print("[Avatar] Response not OK")
|
if IS_DEV { print("[Avatar] Response not OK") }
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let data = json["DATA"] as? [String: Any] ?? json
|
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
|
// Try all possible key variations for avatar URL
|
||||||
let keys = ["AVATAR_URL", "AVATARURL", "AvatarUrl", "avatarUrl", "avatar_url",
|
let keys = ["AVATAR_URL", "AVATARURL", "AvatarUrl", "avatarUrl", "avatar_url",
|
||||||
|
|
@ -707,16 +707,16 @@ actor APIService {
|
||||||
for key in keys {
|
for key in keys {
|
||||||
if let url = data[key] as? String, !url.isEmpty {
|
if let url = data[key] as? String, !url.isEmpty {
|
||||||
let resolved = Self.resolvePhotoUrl(url)
|
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
|
return resolved
|
||||||
}
|
}
|
||||||
if let url = json[key] as? String, !url.isEmpty {
|
if let url = json[key] as? String, !url.isEmpty {
|
||||||
let resolved = Self.resolvePhotoUrl(url)
|
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
|
return resolved
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print("[Avatar] No avatar URL found in response")
|
if IS_DEV { print("[Avatar] No avatar URL found in response") }
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -724,7 +724,7 @@ actor APIService {
|
||||||
func getUserAvatarUrl(userId: Int) async throws -> String? {
|
func getUserAvatarUrl(userId: Int) async throws -> String? {
|
||||||
// Try the avatar endpoint with UserID
|
// Try the avatar endpoint with UserID
|
||||||
let json = try await postJSON("/auth/avatar.php", payload: ["UserID": 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
|
let data = json["DATA"] as? [String: Any] ?? json
|
||||||
|
|
||||||
|
|
@ -733,15 +733,15 @@ actor APIService {
|
||||||
"UserPhotoUrl", "USERPHOTOURL", "userPhotoUrl"]
|
"UserPhotoUrl", "USERPHOTOURL", "userPhotoUrl"]
|
||||||
for key in keys {
|
for key in keys {
|
||||||
if let url = data[key] as? String, !url.isEmpty {
|
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)
|
return Self.resolvePhotoUrl(url)
|
||||||
}
|
}
|
||||||
if let url = json[key] as? String, !url.isEmpty {
|
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)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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() {
|
func stopScanning() {
|
||||||
|
|
@ -137,12 +137,12 @@ final class BeaconScanner: NSObject, ObservableObject {
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
self.resolvedBeacons[key] = servicePointId
|
self.resolvedBeacons[key] = servicePointId
|
||||||
self.pendingResolutions.remove(key)
|
self.pendingResolutions.remove(key)
|
||||||
print("[BeaconScanner] Resolved \(key) -> ServicePointId \(servicePointId)")
|
if IS_DEV { print("[BeaconScanner] Resolved \(key) -> ServicePointId \(servicePointId)") }
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
self.pendingResolutions.remove(key)
|
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 {
|
if rssiSamples.count >= minSamplesToConfirm {
|
||||||
let avg = Double(rssiSamples.reduce(0, +)) / Double(rssiSamples.count)
|
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
|
DispatchQueue.main.async { [weak self] in
|
||||||
self?.onBeaconDetected(avg)
|
self?.onBeaconDetected(avg)
|
||||||
}
|
}
|
||||||
|
|
@ -210,6 +210,6 @@ extension BeaconScanner: CLLocationManagerDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
func locationManager(_ manager: CLLocationManager, didFailRangingFor constraint: CLBeaconIdentityConstraint, error: Error) {
|
func locationManager(_ manager: CLLocationManager, didFailRangingFor constraint: CLBeaconIdentityConstraint, error: Error) {
|
||||||
print("[BeaconScanner] Ranging failed: \(error)")
|
if IS_DEV { print("[BeaconScanner] Ranging failed: \(error)") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ struct AboutScreen: View {
|
||||||
aboutInfo = try await APIService.shared.getAboutInfo()
|
aboutInfo = try await APIService.shared.getAboutInfo()
|
||||||
} catch {
|
} catch {
|
||||||
// Use fallback on error
|
// Use fallback on error
|
||||||
print("Failed to load about info: \(error)")
|
if IS_DEV { print("Failed to load about info: \(error)") }
|
||||||
}
|
}
|
||||||
isLoading = false
|
isLoading = false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
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)
|
startBeaconScanning(d.servicePointId)
|
||||||
} else {
|
} 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 {
|
} catch {
|
||||||
self.error = error.localizedDescription
|
self.error = error.localizedDescription
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue