05/11 Update issue image upload
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user