add ability to rate a missing day
made bgview equatable so it doesn't get redrawn each time a sheet is shown add more string to localization fill in missing data on launch ... incase they have bgfetch turned off
This commit is contained in:
@@ -63,6 +63,36 @@ class ContentModeViewModel: ObservableObject {
|
||||
getGroupedData()
|
||||
}
|
||||
|
||||
public func update(entry: MoodEntry, toMood mood: Mood) {
|
||||
let forDate = entry.forDate!
|
||||
|
||||
if let entry = PersistenceController.shared.getEntry(byDate: entry.forDate!) {
|
||||
PersistenceController.shared.viewContext.delete(entry)
|
||||
}
|
||||
|
||||
do {
|
||||
try PersistenceController.shared.viewContext.save()
|
||||
getGroupedData()
|
||||
} 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.
|
||||
let nsError = error as NSError
|
||||
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
|
||||
PersistenceController.shared.add(mood: mood, forDate: forDate)
|
||||
|
||||
do {
|
||||
try PersistenceController.shared.viewContext.save()
|
||||
getGroupedData()
|
||||
} 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.
|
||||
let nsError = error as NSError
|
||||
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
|
||||
}
|
||||
}
|
||||
|
||||
public func delete(offsets: IndexSet, inMonth month: Int, inYear year: Int) {
|
||||
if let monthEntries = grouped[year],
|
||||
let entries = monthEntries[month] {
|
||||
|
||||
Reference in New Issue
Block a user