🐛 Fixed bug where the app would create new RaPlaEvent objects instead of updating the existing ones

This commit is contained in:
Patrick Müller 2021-02-10 22:20:10 +01:00 committed by Patrick Müller
parent ba0d4da657
commit f5756cd650

View File

@ -156,10 +156,10 @@ class RaPlaFetcher {
// Save the given iCalEvent objects to CoreData
// Updates the events if they already exist and deletes old (/invalid) ones
private class func saveToCoreData(eventObjects: [iCalEvent]) -> Bool{
let existingEvents: [RaPlaEvent] = [] //RaPlaEvent.getAll()
let existingEvents: [RaPlaEvent] = RaPlaEvent.getAll()
var existingEventsDict: [String:RaPlaEvent] = [:]
for event in existingEvents {
existingEventsDict[event.value(forKey: "uid") as! String] = event
existingEventsDict[event.uid!] = event
}
let newEventUIDs = eventObjects.map{$0.uid}