Skip to content

Commit

Permalink
Update core data in main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mssun committed Feb 18, 2020
1 parent 133ad1b commit 2dc8182
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions passKit/Models/PasswordStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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))
}
Expand Down

0 comments on commit 2dc8182

Please sign in to comment.