update code to be mas fun

This commit is contained in:
Trey t
2022-02-03 15:32:58 -06:00
parent 374d2bd954
commit b3aa0d8e32

View File

@@ -18,15 +18,11 @@ class ContentModeViewModel: ObservableObject {
}
private var numberOfEntries: Int {
var num = 0
grouped.keys.forEach({
let year = grouped[$0]
let monthKeys = year?.keys
monthKeys?.forEach({
num += year![$0]!.count
})
})
return num
grouped.keys.map{
grouped[$0]!.values.reduce(0) { sum, array in
sum + array.count
}
}.reduce(0, +)
}
init() {
@@ -40,6 +36,7 @@ class ContentModeViewModel: ObservableObject {
private func getGroupedData() {
grouped = PersistenceController.shared.splitIntoYearMonth()
numberOfItems = numberOfEntries
print(numberOfItems)
}
public func shouldShowVotingHeader() -> Bool {