forked from shadowfacts/Tusker
Fix crash when user refreshes profile before initial pinned statuses request completes
This commit is contained in:
parent
678ed4959b
commit
69c2faf0e1
|
@ -182,7 +182,8 @@ class ProfileStatusesViewController: TimelineLikeTableViewController<TimelineEnt
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mastodonController.persistentContainer.addAll(statuses: newPinnedStatues) {
|
self.mastodonController.persistentContainer.addAll(statuses: newPinnedStatues) {
|
||||||
let oldPinnedStatuses = self.sections[0]
|
// if the user refreshes before the initial pinned statuses request completes, self.sections will be empty
|
||||||
|
let oldPinnedStatuses = self.sections.isEmpty ? [] : self.sections[0]
|
||||||
let pinnedStatues = newPinnedStatues.map { (status) -> TimelineEntry in
|
let pinnedStatues = newPinnedStatues.map { (status) -> TimelineEntry in
|
||||||
let state: StatusState
|
let state: StatusState
|
||||||
if let (_, oldState) = oldPinnedStatuses.first(where: { $0.id == status.id }) {
|
if let (_, oldState) = oldPinnedStatuses.first(where: { $0.id == status.id }) {
|
||||||
|
|
Loading…
Reference in New Issue