mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-15 13:43:43 +01:00
Force fetchLimit for ListPublisher and ListSnapshot
This commit is contained in:
@@ -192,6 +192,17 @@ extension Internals {
|
||||
self.structure.update(sectionIDs: identifiers)
|
||||
}
|
||||
|
||||
mutating func resize(limit: Int) {
|
||||
|
||||
let itemIdentifiers = self.itemIdentifiers
|
||||
guard itemIdentifiers.endIndex > limit else {
|
||||
|
||||
return
|
||||
}
|
||||
self.structure.remove(itemIDs: itemIdentifiers.suffix(from: limit))
|
||||
self.structure.removeAllEmptySections()
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private
|
||||
|
||||
@@ -359,7 +370,7 @@ extension Internals {
|
||||
.insert(contentsOf: items, at: itemIndex)
|
||||
}
|
||||
|
||||
mutating func remove(itemIDs: [NSManagedObjectID]) {
|
||||
mutating func remove<C: Collection>(itemIDs: C) where C.Element == NSManagedObjectID {
|
||||
|
||||
let itemPositionMap = self.itemPositionMap()
|
||||
var removeIndexSetMap: [Int: IndexSet] = [:]
|
||||
@@ -390,6 +401,11 @@ extension Internals {
|
||||
}
|
||||
}
|
||||
|
||||
mutating func removeAllEmptySections() {
|
||||
|
||||
self.sections.removeAll(where: { $0.elements.isEmpty })
|
||||
}
|
||||
|
||||
mutating func move(itemID: NSManagedObjectID, before beforeItemID: NSManagedObjectID) {
|
||||
|
||||
guard let removed = self.remove(itemID: itemID) else {
|
||||
|
||||
@@ -93,6 +93,11 @@ extension Internals {
|
||||
var snapshot = Internals.DiffableDataSourceSnapshot(
|
||||
sections: controller.sections ?? []
|
||||
)
|
||||
let fetchLimit = controller.fetchRequest.fetchLimit
|
||||
if fetchLimit > 0 {
|
||||
|
||||
snapshot.resize(limit: fetchLimit)
|
||||
}
|
||||
snapshot.reloadSections(self.reloadedSectionIDs)
|
||||
snapshot.reloadItems(self.reloadedItemIDs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user