From 676e603ffc9b9fb03e754edda4685ecee888e66e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 10 Nov 2023 14:04:11 -0500 Subject: [PATCH] Fix crash when showing trending hashtag with less than two days of history --- .../Views/Hashtag Cell/TrendingHashtagCollectionViewCell.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tusker/Views/Hashtag Cell/TrendingHashtagCollectionViewCell.swift b/Tusker/Views/Hashtag Cell/TrendingHashtagCollectionViewCell.swift index 9bde0085..a0de3bf8 100644 --- a/Tusker/Views/Hashtag Cell/TrendingHashtagCollectionViewCell.swift +++ b/Tusker/Views/Hashtag Cell/TrendingHashtagCollectionViewCell.swift @@ -67,7 +67,8 @@ class TrendingHashtagCollectionViewCell: UICollectionViewCell { historyView.setHistory(hashtag.history) 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 lastTwo = sorted[(sorted.count - 2)...] let accounts = lastTwo.map(\.accounts).reduce(0, +)