From 402e12a074f0e2b8ac06192e7d8126d8648f0aab Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 12 Sep 2022 22:38:13 -0400 Subject: [PATCH] Set automaticallyMergesChangesFromParent on NSManagedObjectContexts --- Persistence/Sources/Persistence/PersistentContainer.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Persistence/Sources/Persistence/PersistentContainer.swift b/Persistence/Sources/Persistence/PersistentContainer.swift index 615fe1a..a0094a8 100644 --- a/Persistence/Sources/Persistence/PersistentContainer.swift +++ b/Persistence/Sources/Persistence/PersistentContainer.swift @@ -22,6 +22,7 @@ public class PersistentContainer: NSPersistentContainer, @unchecked Sendable { // the background context needs to be parented directly to the PSC // if it's parented to the viewContext, it blocks the viewContext (and potentially the main thread) when it needs to look things up context.persistentStoreCoordinator = self.persistentStoreCoordinator + context.automaticallyMergesChangesFromParent = true return context }() @@ -62,6 +63,8 @@ public class PersistentContainer: NSPersistentContainer, @unchecked Sendable { fatalError("Unable to load persistent store: \(error)") } } + + viewContext.automaticallyMergesChangesFromParent = true } @MainActor