Fix TimelineLikeCollectionViewController.apply not actually applying snapshots on the main thread

This commit is contained in:
Shadowfacts 2023-11-05 18:22:20 -05:00
parent 4c5da1b5a9
commit e6f1968609
1 changed files with 3 additions and 2 deletions

View File

@ -211,9 +211,10 @@ extension TimelineLikeCollectionViewController {
extension TimelineLikeCollectionViewController {
// apply(_:animatingDifferences:) is marked as nonisolated, so just awaiting it doesn't dispatch to the main thread, unlike other async @MainActor methods
// but we always want to update the data source on the main thread for consistency, so this method does that
@MainActor
func apply(_ snapshot: NSDiffableDataSourceSnapshot<Section, Item>, animatingDifferences: Bool) async {
await self.dataSource.apply(snapshot, animatingDifferences: animatingDifferences)
await MainActor.run {
dataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
}
}
@MainActor