Fix crash when adding pinned statuses section during refresh

This commit is contained in:
Shadowfacts 2021-02-08 18:24:44 -05:00
parent e4ff632dcb
commit 6e92633793
1 changed files with 7 additions and 6 deletions

View File

@ -196,13 +196,14 @@ class ProfileStatusesViewController: TimelineLikeTableViewController<TimelineEnt
return (status.id, state)
}
DispatchQueue.main.async {
if self.sections.count < 1 {
self.sections.append(pinnedStatues)
} else {
self.sections[0] = pinnedStatues
}
UIView.performWithoutAnimation {
self.tableView.reloadSections(IndexSet(integer: 0), with: .none)
if self.sections.count < 1 {
self.sections.append(pinnedStatues)
self.tableView.insertSections(IndexSet(integer: 0), with: .none)
} else {
self.sections[0] = pinnedStatues
self.tableView.reloadSections(IndexSet(integer: 0), with: .none)
}
}
}
}