Add lead workflows, PDF signing, AR projects and photo gallery integration

This commit is contained in:
Dennis Nemec
2026-11-08 17:49:39 +01:00
parent a343bde741
commit 8d18873412
82 changed files with 6401 additions and 34 deletions

View File

@ -0,0 +1,27 @@
import Foundation
import SwiftData
/// Reads project photos through the lead association in a fresh context after AR closes.
@MainActor
final class LeadARPhotoStore {
private let context: ModelContext
init(container: ModelContainer) {
context = ModelContext(container)
context.autosaveEnabled = false
}
func photos(for leadID: String) throws -> [ProjectPhoto] {
let links = try context.fetch(FetchDescriptor<LeadARProjectLink>(
predicate: #Predicate { $0.leadID == leadID }))
let legacy = try context.fetch(FetchDescriptor<Project>(
predicate: #Predicate { $0.leadID == leadID }))
var projects = links.compactMap(\.project)
let linkedIDs = Set(projects.map(\.projectID))
projects.append(contentsOf: legacy.filter { !linkedIDs.contains($0.projectID) })
var seen = Set<PersistentIdentifier>()
return projects.flatMap(\.photos)
.filter { seen.insert($0.persistentModelID).inserted }
.sorted { $0.creationDate > $1.creationDate }
}
}