fixed issue when adding multiple missing entries

This commit is contained in:
Trey t
2022-02-17 17:50:17 -06:00
parent 2130b621d1
commit 7b828cc93c
3 changed files with 7 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ enum EntryType: Int {
case notification
case header
case listView
case filledInMissing
}
extension MoodEntry {

View File

@@ -56,7 +56,10 @@ extension PersistenceController {
let existingEntriesSet = Set(existingEntries)
let missing = Array(allDatesSet.subtracting(existingEntriesSet)).sorted(by: >)
for date in missing {
add(mood: .missing, forDate: date, entryType: .listView)
// add 12 hours, if you enter a things right at 12:00.00 it wont show .... mabye
// due to utc offset?
let adjustedDate = Calendar.current.date(byAdding: .hour, value: 12, to: date)!
add(mood: .missing, forDate: adjustedDate, entryType: .filledInMissing)
}
}
}

View File

@@ -91,7 +91,8 @@ struct ContentView: View {
}
if let selectedEntry = selectedEntry,
deleteEnabled{
deleteEnabled,
selectedEntry.mood != .missing {
Button(String(localized: "content_view_delete_entry"), action: {
viewModel.update(entry: selectedEntry, toMood: Mood.missing)
showUpdateEntryAlert = false