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
This commit is contained in:
Shadowfacts 2020-05-13 19:49:35 -04:00
parent 35a510e8ed
commit d396eb0823
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 5 additions and 1 deletions

View File

@ -18,7 +18,11 @@ class MastodonCachePersistentStore: NSPersistentContainer {
return NSManagedObjectModel(contentsOf: url)! 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<String, Never>() let statusSubject = PassthroughSubject<String, Never>()
let accountSubject = PassthroughSubject<String, Never>() let accountSubject = PassthroughSubject<String, Never>()