Update core data in main thread

This commit is contained in:
Mingshen Sun 2020-02-18 11:03:56 -08:00
parent 133ad1bd45
commit 2dc8182fe8
No known key found for this signature in database
GPG key ID: 1F86BA2052FED3B4

View file

@ -235,8 +235,8 @@ public class PasswordStore {
try storeRepository.pull(storeRepository.currentBranch(), from: remote, withOptions: options, progress: progressBlock)
Defaults.lastSyncedTime = Date()
self.setAllSynced()
self.updatePasswordEntityCoreData()
DispatchQueue.main.async {
self.updatePasswordEntityCoreData()
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
}
}
@ -566,7 +566,9 @@ public class PasswordStore {
public func saveUpdatedContext() {
do {
try context.save()
if context.hasChanges {
try context.save()
}
} catch {
fatalError("FailureToSaveContext".localize(error))
}