update top header graph view when custom color changes
code cleanup
This commit is contained in:
@@ -41,10 +41,12 @@ class HomeViewViewModel: ObservableObject {
|
||||
|
||||
PersistenceController.shared.switchContainerListeners.append {
|
||||
self.getGroupedData(addMonthStartWeekdayPadding: self.addMonthStartWeekdayPadding)
|
||||
|
||||
}
|
||||
PersistenceController.shared.listeners.append { [weak self] in
|
||||
self?.updateData()
|
||||
|
||||
PersistenceController.shared.addNewDataListener {
|
||||
withAnimation{
|
||||
self.updateData()
|
||||
}
|
||||
}
|
||||
updateData()
|
||||
}
|
||||
@@ -55,7 +57,7 @@ class HomeViewViewModel: ObservableObject {
|
||||
if addMonthStartWeekdayPadding {
|
||||
grouped = MoodEntryFunctions.padMoodEntriesForCalendar(entries: grouped)
|
||||
}
|
||||
|
||||
//
|
||||
numberOfItems = numberOfEntries
|
||||
}
|
||||
|
||||
@@ -67,12 +69,11 @@ class HomeViewViewModel: ObservableObject {
|
||||
|
||||
public func add(mood: Mood, forDate date: Date, entryType: EntryType) {
|
||||
PersistenceController.shared.add(mood: mood, forDate: date, entryType: entryType)
|
||||
updateData()
|
||||
}
|
||||
|
||||
public func update(entry: MoodEntry, toMood mood: Mood) {
|
||||
if PersistenceController.shared.update(entryDate: entry.forDate!, withModd: mood) {
|
||||
updateData()
|
||||
if !PersistenceController.shared.update(entryDate: entry.forDate!, withModd: mood) {
|
||||
#warning("show error")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +97,6 @@ class HomeViewViewModel: ObservableObject {
|
||||
|
||||
do {
|
||||
try PersistenceController.shared.viewContext.save()
|
||||
updateData()
|
||||
} catch {
|
||||
// Replace this implementation with code to handle the error appropriately.
|
||||
// fatalError() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||
|
||||
Reference in New Issue
Block a user