closed #78
This commit is contained in:
@@ -34,7 +34,7 @@ class PersistenceController {
|
||||
return data.first
|
||||
}
|
||||
|
||||
public func add(mood: Mood, forDate date: Date) {
|
||||
public func add(mood: Mood, forDate date: Date, entryType: EntryType) {
|
||||
if let existingEntry = getEntry(byDate: date) {
|
||||
viewContext.delete(existingEntry)
|
||||
try? viewContext.save()
|
||||
@@ -47,6 +47,7 @@ class PersistenceController {
|
||||
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: date))
|
||||
newItem.canEdit = true
|
||||
newItem.canDelete = true
|
||||
newItem.entryType = Int16(entryType.rawValue)
|
||||
|
||||
do {
|
||||
try viewContext.save()
|
||||
@@ -163,7 +164,7 @@ class PersistenceController {
|
||||
let existingEntriesSet = Set(existingEntries)
|
||||
let missing = Array(allDatesSet.subtracting(existingEntriesSet)).sorted(by: >)
|
||||
for date in missing {
|
||||
add(mood: .missing, forDate: date)
|
||||
add(mood: .missing, forDate: date, entryType: .listView)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,6 +220,8 @@ class PersistenceController {
|
||||
for description in container.persistentStoreDescriptions {
|
||||
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)
|
||||
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
|
||||
description.setOption(true as NSNumber, forKey: NSMigratePersistentStoresAutomaticallyOption)
|
||||
description.setOption(true as NSNumber, forKey: NSInferMappingModelAutomaticallyOption)
|
||||
}
|
||||
|
||||
container.loadPersistentStores(completionHandler: { (storeDescription, error) in
|
||||
|
||||
Reference in New Issue
Block a user