From aa0955917f87ff23f5124b7274709baa4c6d6f01 Mon Sep 17 00:00:00 2001 From: Laurent Date: Fri, 14 Feb 2025 14:24:44 +0100 Subject: [PATCH] fix thread issue --- PadelClub/PadelClubApp.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PadelClub/PadelClubApp.swift b/PadelClub/PadelClubApp.swift index b718dbc..35e88fd 100644 --- a/PadelClub/PadelClubApp.swift +++ b/PadelClub/PadelClubApp.swift @@ -122,7 +122,7 @@ struct PadelClubApp: App { Task.detached(priority: .high) { if let requiredVersion = await self._retrieveRequiredVersion() { let cleanedRequired = requiredVersion.replacingOccurrences(of: "\n", with: "") - Logger.log(">>> VERSION = \(requiredVersion)") + Logger.log(">>> REQUIRED VERSION = \(requiredVersion)") if let currentVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { await MainActor.run { self.blockApp = VersionComparator.compare(cleanedRequired, currentVersion) == 1 @@ -134,9 +134,16 @@ struct PadelClubApp: App { fileprivate func _retrieveRequiredVersion() async -> String? { let requiredVersionURL = URLs.main.extend(path: "static/misc/required-version.txt") - return try? String(contentsOf: requiredVersionURL, encoding: .utf8) + + do { + let (data, _) = try await URLSession.shared.data(from: requiredVersionURL) + return String(data: data, encoding: .utf8) + } catch { + Logger.log("Error fetching required version: \(error)") + return nil + } } - + private func _handleIncomingURL(_ url: URL) { // Parse the URL let pathComponents = url.pathComponents