Skip to content

Commit

Permalink
Remove fake updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ManWithBear authored and VojtaStavik committed Feb 8, 2021
1 parent 5e97f8a commit f22b62e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Sources/StreamChat/Database/DatabaseContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ class DatabaseContainer: NSPersistentContainer {
log.debug("Starting a database session.")
do {
try actions(self.writableContext)
// If you touch ManagedObject and update one of it properties to same value
// Object will be marked as `updated` even it hasn't changed.
// By reseting such objects we remove updates that are not updates.
for object in self.writableContext.updatedObjects {
if object.changedValues().isEmpty {
self.writableContext.refresh(object, mergeChanges: false)
}
}

if self.writableContext.hasChanges {
log.debug("Context has changes. Saving.")
Expand Down

0 comments on commit f22b62e

Please sign in to comment.