closed #56
This commit is contained in:
@@ -11,11 +11,24 @@ import CoreData
|
||||
class ContentModeViewModel: ObservableObject {
|
||||
@Published var grouped = [Int: [Int: [MoodEntry]]]()
|
||||
@Published public private(set) var savedOnboardingData = UserDefaultsStore.getOnboarding()
|
||||
|
||||
@Published var numberOfItems = 0
|
||||
|
||||
var hasNoData: Bool {
|
||||
grouped.isEmpty
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
init() {
|
||||
PersistenceController.shared.switchContainerListeners.append {
|
||||
self.getGroupedData()
|
||||
@@ -26,6 +39,7 @@ class ContentModeViewModel: ObservableObject {
|
||||
|
||||
private func getGroupedData() {
|
||||
grouped = PersistenceController.shared.splitIntoYearMonth()
|
||||
numberOfItems = numberOfEntries
|
||||
}
|
||||
|
||||
public func shouldShowVotingHeader() -> Bool {
|
||||
|
||||
Reference in New Issue
Block a user