forked from shadowfacts/Tusker
Fix error when refreshing timeline with no items
This commit is contained in:
parent
527706154a
commit
21299c8eb8
|
@ -315,7 +315,7 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
} else {
|
||||
// I'm not sure whether this should move into TimelineLikeController/TimelineLikeCollectionViewController
|
||||
let (_, presentItems) = await (controller.loadNewer(), try? loadInitial())
|
||||
if let presentItems {
|
||||
if let presentItems, !presentItems.isEmpty {
|
||||
insertPresentItemsIfNecessary(presentItems)
|
||||
}
|
||||
}
|
||||
|
@ -334,6 +334,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro
|
|||
|
||||
private func insertPresentItemsIfNecessary(_ presentItems: [String]) {
|
||||
var snapshot = dataSource.snapshot()
|
||||
guard snapshot.indexOfSection(.statuses) != nil else {
|
||||
return
|
||||
}
|
||||
let currentItems = snapshot.itemIdentifiers(inSection: .statuses)
|
||||
if case .status(id: let firstID, state: _) = currentItems.first,
|
||||
// if there's no overlap between presentItems and the existing items in the data source, insert the present items and prompt the user
|
||||
|
|
Loading…
Reference in New Issue