05/11 Update issue image upload

This commit is contained in:
Nguyen Ngo
2026-05-11 17:31:21 -04:00
parent 6367dac1e6
commit 9fd3f5b829
6 changed files with 223 additions and 67 deletions
+7 -7
View File
@@ -95,15 +95,15 @@ class SyncManager: ObservableObject {
inspections?.first?.setValue(serverPath, forFieldId: fieldId)
}
// Update parent issue photo path
// Update parent issue photo paths array
if photo.entityType == "issue" {
let entityId = photo.entityLocalId
let issues = try? context.fetch(
FetchDescriptor<LocalIssue>(
predicate: #Predicate { $0.localId == entityId }
)
)
issues?.first?.photoServerPath = serverPath
let allIssues = (try? context.fetch(FetchDescriptor<LocalIssue>())) ?? []
if let issue = allIssues.first(where: { $0.localId == entityId }) {
var paths = issue.photoServerPaths
if !paths.contains(serverPath) { paths.append(serverPath) }
issue.photoServerPaths = paths
}
}
try? context.save()