Fix history search

This commit is contained in:
Selim Mustafaev 2023-01-17 23:32:26 +03:00
parent 3b691345d8
commit 235b9e8f43

View File

@ -17,6 +17,7 @@ class RealmSectionedDataSource<Item,Cell>: NSObject, UITableViewDataSource
private var sections: [DateSection<Item>] = [] private var sections: [DateSection<Item>] = []
private var cellIdentifier: String private var cellIdentifier: String
private var filterPredicate: FilterPredicate<Item>? private var filterPredicate: FilterPredicate<Item>?
private let groupQueue = DispatchQueue(label: "group")
private let onSizeChanged: ((Int) -> Void)? private let onSizeChanged: ((Int) -> Void)?
@ -94,13 +95,15 @@ class RealmSectionedDataSource<Item,Cell>: NSObject, UITableViewDataSource
items = items.filter(predicate) items = items.filter(predicate)
} }
DispatchQueue.global().async { self.groupQueue.async {
let newSections = items.groupedByDate() let newSections = items.groupedByDate()
let changeset = StagedChangeset(source: self.sections, target: newSections) // let changeset = StagedChangeset(source: self.sections, target: newSections)
DispatchQueue.main.async { DispatchQueue.main.async {
self.tv.reload(using: changeset, with: animated ? .fade : .none) { newSects in self.sections = newSections
self.sections = newSects self.tv.reloadData()
} // self.tv.reload(using: changeset, with: animated ? .fade : .none) { newSects in
// self.sections = newSects
// }
} }
} }
} }