Skip to content

Commit 2dc8182

Browse files
committed
Update core data in main thread
1 parent 133ad1b commit 2dc8182

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

passKit/Models/PasswordStore.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ public class PasswordStore {
235235
try storeRepository.pull(storeRepository.currentBranch(), from: remote, withOptions: options, progress: progressBlock)
236236
Defaults.lastSyncedTime = Date()
237237
self.setAllSynced()
238-
self.updatePasswordEntityCoreData()
239238
DispatchQueue.main.async {
239+
self.updatePasswordEntityCoreData()
240240
NotificationCenter.default.post(name: .passwordStoreUpdated, object: nil)
241241
}
242242
}
@@ -566,7 +566,9 @@ public class PasswordStore {
566566

567567
public func saveUpdatedContext() {
568568
do {
569-
try context.save()
569+
if context.hasChanges {
570+
try context.save()
571+
}
570572
} catch {
571573
fatalError("FailureToSaveContext".localize(error))
572574
}

0 commit comments

Comments
 (0)