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,12 +196,12 @@ class ProfileStatusesViewController: TimelineLikeTableViewController<TimelineEnt
return (status.id, state) return (status.id, state)
} }
DispatchQueue.main.async { DispatchQueue.main.async {
UIView.performWithoutAnimation {
if self.sections.count < 1 { if self.sections.count < 1 {
self.sections.append(pinnedStatues) self.sections.append(pinnedStatues)
self.tableView.insertSections(IndexSet(integer: 0), with: .none)
} else { } else {
self.sections[0] = pinnedStatues self.sections[0] = pinnedStatues
}
UIView.performWithoutAnimation {
self.tableView.reloadSections(IndexSet(integer: 0), with: .none) self.tableView.reloadSections(IndexSet(integer: 0), with: .none)
} }
} }
@ -209,6 +209,7 @@ class ProfileStatusesViewController: TimelineLikeTableViewController<TimelineEnt
} }
} }
} }
}
// MARK: - UITableViewDatasource // MARK: - UITableViewDatasource
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {