forked from shadowfacts/Tusker
Fix crash when showing trending hashtag with less than two days of history
This commit is contained in:
parent
cb47443649
commit
676e603ffc
|
@ -67,7 +67,8 @@ class TrendingHashtagCollectionViewCell: UICollectionViewCell {
|
||||||
historyView.setHistory(hashtag.history)
|
historyView.setHistory(hashtag.history)
|
||||||
historyView.isHidden = hashtag.history == nil || hashtag.history!.count < 2
|
historyView.isHidden = hashtag.history == nil || hashtag.history!.count < 2
|
||||||
|
|
||||||
if let history = hashtag.history {
|
if let history = hashtag.history,
|
||||||
|
history.count >= 2 {
|
||||||
let sorted = history.sorted(by: { $0.day < $1.day })
|
let sorted = history.sorted(by: { $0.day < $1.day })
|
||||||
let lastTwo = sorted[(sorted.count - 2)...]
|
let lastTwo = sorted[(sorted.count - 2)...]
|
||||||
let accounts = lastTwo.map(\.accounts).reduce(0, +)
|
let accounts = lastTwo.map(\.accounts).reduce(0, +)
|
||||||
|
|
Loading…
Reference in New Issue