From d396eb082302f59e509675197d4f2129ed3d9112 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 13 May 2020 19:49:35 -0400 Subject: [PATCH] Change background CoreData context to be a child of the main context so that updates on the background context propogate up to the view context on save --- Tusker/CoreData/MastodonCachePersistentStore.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tusker/CoreData/MastodonCachePersistentStore.swift b/Tusker/CoreData/MastodonCachePersistentStore.swift index 419c4955..9b491112 100644 --- a/Tusker/CoreData/MastodonCachePersistentStore.swift +++ b/Tusker/CoreData/MastodonCachePersistentStore.swift @@ -18,7 +18,11 @@ class MastodonCachePersistentStore: NSPersistentContainer { return NSManagedObjectModel(contentsOf: url)! }() - private(set) lazy var backgroundContext = newBackgroundContext() + private(set) lazy var backgroundContext: NSManagedObjectContext = { + let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType) + context.parent = self.viewContext + return context + }() let statusSubject = PassthroughSubject() let accountSubject = PassthroughSubject()