From 9c44a2620148f1595fc3225b47362d9da26f4151 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Fri, 23 Sep 2022 22:11:53 +0300 Subject: [PATCH] Sorting events in vehicles --- AutoCat.xcodeproj/project.pbxproj | 4 ++-- AutoCatCore/Models/Vehicle.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index fb7b834..547d625 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -1080,7 +1080,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -1105,7 +1105,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 94; + CURRENT_PROJECT_VERSION = 95; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; diff --git a/AutoCatCore/Models/Vehicle.swift b/AutoCatCore/Models/Vehicle.swift index 910804f..bb48253 100644 --- a/AutoCatCore/Models/Vehicle.swift +++ b/AutoCatCore/Models/Vehicle.swift @@ -259,7 +259,7 @@ public class Vehicle: Object, Decodable, Identifiable, Differentiable, Cloneable } if let eventsArray = try container.decodeIfPresent([VehicleEvent].self, forKey: .events) { - self.events.append(objectsIn: eventsArray) + self.events.append(objectsIn: eventsArray.sorted { $0.date > $1.date }) } if let osago = try container.decodeIfPresent([Osago].self, forKey: .osagoContracts) { @@ -343,7 +343,7 @@ public class Vehicle: Object, Decodable, Identifiable, Differentiable, Cloneable self.ownershipPeriods = ownerships let events = List() - events.append(objectsIn: copy.events.map { $0.clone() }) + events.append(objectsIn: copy.events.map { $0.clone() }.sorted { $0.date > $1.date }) self.events = events let osago = List()