From f813fff8e439b6da011f98cd060037930fb1f101 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Sat, 18 Oct 2025 13:48:57 +0300 Subject: [PATCH] Fix for locations in voice records --- AutoCat.xcodeproj/project.pbxproj | 4 ++-- .../VehicleRecordService/VehicleRecordService.swift | 10 ++++++---- AutoCatCore/Utils/Constants.swift | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index e7a28af..2d82796 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -1721,7 +1721,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 173; + CURRENT_PROJECT_VERSION = 174; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = AutoCat; @@ -1750,7 +1750,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 173; + CURRENT_PROJECT_VERSION = 174; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = AutoCat; diff --git a/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift b/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift index d007d2c..04a182c 100644 --- a/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift +++ b/AutoCatCore/Services/VehicleRecordService/VehicleRecordService.swift @@ -21,6 +21,7 @@ public actor VehicleRecordService { @AutoCancellable var locationTask: Task? + var locationTaskActive = false public init( recordService: AudioRecordServiceProtocol, @@ -103,14 +104,15 @@ extension VehicleRecordService: VehicleRecordServiceProtocol { try await recordService.startRecording(to: url) - if locationTask == nil || locationTask?.isCancelled == true { + if !locationTaskActive { + locationTaskActive = true locationTask = Task { do { let location = try await locationService.getRecentLocation() - locationTask = nil + locationTaskActive = false return location } catch { - locationTask = nil + locationTaskActive = false return nil } } @@ -130,8 +132,8 @@ extension VehicleRecordService: VehicleRecordServiceProtocol { async let recognitionTask = recordService.recognizeText(from: url) async let durationTask = recordService.getDuration(from: url) - let (text, duration) = await (recognitionTask, try? durationTask) var location = try? await locationTask?.value + let (text, duration) = await (recognitionTask, try? durationTask) // One location can be shared between multile records // So, manually give each copy it's unique id diff --git a/AutoCatCore/Utils/Constants.swift b/AutoCatCore/Utils/Constants.swift index 8f623ed..1a5a21d 100644 --- a/AutoCatCore/Utils/Constants.swift +++ b/AutoCatCore/Utils/Constants.swift @@ -19,8 +19,8 @@ public enum Constants { public var baseUrl: String { #if DEBUG - "http://127.0.0.1:3000/" - //"https://charon.aliencat.pro:8444/" + //"http://127.0.0.1:3000/" + "https://charon.aliencat.pro:8444/" #else rawValue #endif