forked from shadowfacts/Tusker
Deduplicate updated timeline positions when handling remote changes
This commit is contained in:
parent
ae7962ae50
commit
f9e619d9e7
|
@ -507,10 +507,11 @@ class MastodonCachePersistentStore: NSPersistentCloudKitContainer {
|
||||||
let req = NSPersistentHistoryChangeRequest.fetchHistory(after: self.lastRemoteChangeToken)
|
let req = NSPersistentHistoryChangeRequest.fetchHistory(after: self.lastRemoteChangeToken)
|
||||||
self.backgroundContext.performAndWait {
|
self.backgroundContext.performAndWait {
|
||||||
if let result = try? self.backgroundContext.execute(req) as? NSPersistentHistoryResult,
|
if let result = try? self.backgroundContext.execute(req) as? NSPersistentHistoryResult,
|
||||||
let transactions = result.result as? [NSPersistentHistoryTransaction] {
|
let transactions = result.result as? [NSPersistentHistoryTransaction],
|
||||||
|
!transactions.isEmpty {
|
||||||
var changedHashtags = false
|
var changedHashtags = false
|
||||||
var changedInstances = false
|
var changedInstances = false
|
||||||
var changedTimelinePositions: [NSManagedObjectID] = []
|
var changedTimelinePositions = Set<NSManagedObjectID>()
|
||||||
var changedAccountPrefs = false
|
var changedAccountPrefs = false
|
||||||
outer: for transaction in transactions {
|
outer: for transaction in transactions {
|
||||||
for change in transaction.changes ?? [] {
|
for change in transaction.changes ?? [] {
|
||||||
|
@ -519,7 +520,7 @@ class MastodonCachePersistentStore: NSPersistentCloudKitContainer {
|
||||||
} else if change.changedObjectID.entity.name == "SavedInstance" {
|
} else if change.changedObjectID.entity.name == "SavedInstance" {
|
||||||
changedInstances = true
|
changedInstances = true
|
||||||
} else if change.changedObjectID.entity.name == "TimelinePosition" {
|
} else if change.changedObjectID.entity.name == "TimelinePosition" {
|
||||||
changedTimelinePositions.append(change.changedObjectID)
|
changedTimelinePositions.insert(change.changedObjectID)
|
||||||
} else if change.changedObjectID.entity.name == "AccountPreferences" {
|
} else if change.changedObjectID.entity.name == "AccountPreferences" {
|
||||||
changedAccountPrefs = true
|
changedAccountPrefs = true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue