mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 20:54:51 +00:00
askdjf
This commit is contained in:
1 file changed
+14
-12
@@ -23,18 +23,18 @@ struct EmojiTableView: UIViewRepresentable {
|
|||||||
func updateUIView(_ uiView: UITableView, context: Context) {
|
func updateUIView(_ uiView: UITableView, context: Context) {
|
||||||
context.coordinator.hoarder = hoarder
|
context.coordinator.hoarder = hoarder
|
||||||
|
|
||||||
|
weak let dataSourceRef: UITableViewDiffableDataSource<Int, String>! = uiView.dataSource as? UITableViewDiffableDataSource<Int, String>
|
||||||
|
var snapshotBefore = dataSourceRef.snapshot()
|
||||||
let itemsBefore = context.coordinator.items
|
let itemsBefore = context.coordinator.items
|
||||||
let itemsAfter = items
|
let itemsAfter = items
|
||||||
context.coordinator.items = items
|
context.coordinator.items = items
|
||||||
// guard itemsBefore != itemsAfter else { return }
|
|
||||||
Task.detached {
|
Task.detached {
|
||||||
// if !(-10_000...10_000).contains(itemsBefore.count-itemsAfter.count) ||
|
guard !itemsAfter.isEmpty else {
|
||||||
// itemsAfter == itemsBefore {
|
snapshotBefore.deleteAllItems()
|
||||||
// //diff of more than 10k
|
dataSourceRef.apply(snapshotBefore, animatingDifferences: true)
|
||||||
// await context.coordinator.instantApplySnapshot()
|
return
|
||||||
// } else {
|
}
|
||||||
await context.coordinator.applySnapshot(animated: true)
|
dataSourceRef.apply(context.coordinator.makeSnapshot(), animatingDifferences: true)
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,15 +67,17 @@ struct EmojiTableView: UIViewRepresentable {
|
|||||||
snapshot.appendItems(items, toSection: 0)
|
snapshot.appendItems(items, toSection: 0)
|
||||||
return snapshot
|
return snapshot
|
||||||
}
|
}
|
||||||
|
|
||||||
func applySnapshot(animated: Bool) async {
|
func applySnapshot(animated: Bool) async {
|
||||||
let snapshot = makeSnapshot()
|
let snapshot = makeSnapshot()
|
||||||
await (self.tableView.dataSource as! UITableViewDiffableDataSource).apply(snapshot, animatingDifferences: animated)
|
(self.tableView.dataSource as! UITableViewDiffableDataSource).apply(snapshot, animatingDifferences: animated) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func instantApplySnapshot() async {
|
func instantApplySnapshot() async {
|
||||||
let snapshot = makeSnapshot()
|
let snapshot = makeSnapshot()
|
||||||
await (self.tableView.dataSource as! UITableViewDiffableDataSource).applySnapshotUsingReloadData(snapshot)
|
(self.tableView.dataSource as! UITableViewDiffableDataSource).applySnapshotUsingReloadData(snapshot) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func cell(
|
func cell(
|
||||||
|
|||||||