diff --git a/AutoCat.xcodeproj/project.pbxproj b/AutoCat.xcodeproj/project.pbxproj index 8034b12..4752346 100644 --- a/AutoCat.xcodeproj/project.pbxproj +++ b/AutoCat.xcodeproj/project.pbxproj @@ -728,7 +728,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; @@ -750,7 +750,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 48; + CURRENT_PROJECT_VERSION = 49; DEVELOPMENT_TEAM = 46DTTB8X4S; INFOPLIST_FILE = AutoCat/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; diff --git a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist index f9e3a76..ce4c584 100644 --- a/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/AutoCat.xcodeproj/xcuserdata/selim.xcuserdatad/xcschemes/xcschememanagement.plist @@ -14,35 +14,35 @@ isShown orderHint - 8 + 5 DifferenceKit (Playground) 2.xcscheme isShown orderHint - 9 + 6 DifferenceKit (Playground).xcscheme isShown orderHint - 7 + 4 Eureka (Playground) 1.xcscheme isShown orderHint - 3 + 8 Eureka (Playground) 2.xcscheme isShown orderHint - 4 + 9 Eureka (Playground) 3.xcscheme @@ -70,7 +70,7 @@ isShown orderHint - 2 + 7 GettingStarted (Playground) 1.xcscheme @@ -112,42 +112,42 @@ isShown orderHint - 13 + 12 Rx (Playground) 1.xcscheme isShown orderHint - 6 + 1 Rx (Playground) 2.xcscheme isShown orderHint - 5 + 3 Rx (Playground).xcscheme isShown orderHint - 1 + 2 SwiftDate (Playground) 1.xcscheme isShown orderHint - 10 + 11 SwiftDate (Playground) 2.xcscheme isShown orderHint - 12 + 13 SwiftDate (Playground) 3.xcscheme @@ -175,7 +175,7 @@ isShown orderHint - 11 + 10 SuppressBuildableAutocreation diff --git a/AutoCat/AppDelegate.swift b/AutoCat/AppDelegate.swift index 9134a7b..cda7a91 100644 --- a/AutoCat/AppDelegate.swift +++ b/AutoCat/AppDelegate.swift @@ -25,7 +25,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { let config = Realm.Configuration( - schemaVersion: 21, + schemaVersion: 22, migrationBlock: { migration, oldSchemaVersion in if oldSchemaVersion <= 3 { var numbers: [String] = [] @@ -80,6 +80,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } } } + + if oldSchemaVersion <= 21 { + migration.enumerateObjects(ofType: "Vehicle") { old, new in + if let oldEngineVolume = (old?["engine"] as? MigrationObject)?["volume"] as? Int { + (new?["engine"] as? MigrationObject)?["volume"] = RealmOptional(oldEngineVolume) + } else { + (new?["engine"] as? MigrationObject)?["volume"] = RealmOptional(0) + } + } + } }) Realm.Configuration.defaultConfiguration = config diff --git a/AutoCat/Controllers/CheckController.swift b/AutoCat/Controllers/CheckController.swift index de490b9..7c94f26 100644 --- a/AutoCat/Controllers/CheckController.swift +++ b/AutoCat/Controllers/CheckController.swift @@ -241,7 +241,7 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat return Single.just(event) } - if let event = LocationManager.lastEvent, (Date().timeIntervalSince1970 - event.date) < 30 { + if let event = LocationManager.lastEvent, (Date().timeIntervalSince1970 - event.date) < 10 { return Single.just(event) } else { return LocationManager.requestCurrentLocation() diff --git a/AutoCat/Controllers/ReportController.swift b/AutoCat/Controllers/ReportController.swift index e5a1465..4db96dc 100644 --- a/AutoCat/Controllers/ReportController.swift +++ b/AutoCat/Controllers/ReportController.swift @@ -233,7 +233,7 @@ class ReportController: UIViewController, UICollectionViewDataSource, UICollecti cell?.configure(param: engineSection.description, value: engine.fuelType ?? "") break case .volume: - cell?.configure(param: engineSection.description, value: String(engine.volume)) + cell?.configure(param: engineSection.description, value: String(engine.volume.value ?? 0)) break case .powerHp: cell?.configure(param: engineSection.description, value: String(engine.powerHp)) diff --git a/AutoCat/Extensions/VehicleReportImage.swift b/AutoCat/Extensions/VehicleReportImage.swift index 7174e6d..d4598e8 100644 --- a/AutoCat/Extensions/VehicleReportImage.swift +++ b/AutoCat/Extensions/VehicleReportImage.swift @@ -110,7 +110,7 @@ extension Vehicle { y += cellHeight self.drawCell(y: y, width: w, height: cellHeight, title: "Fuel type", value: self.engine?.fuelType ?? "", context: ctx) y += cellHeight - self.drawCell(y: y, width: w, height: cellHeight, title: "Volume (cm³)", value: String(self.engine?.volume ?? 0), context: ctx) + self.drawCell(y: y, width: w, height: cellHeight, title: "Volume (cm³)", value: String(self.engine?.volume.value ?? 0), context: ctx) y += cellHeight self.drawCell(y: y, width: w, height: cellHeight, title: "Power (HP)", value: String(self.engine?.powerHp ?? 0), context: ctx) y += cellHeight diff --git a/AutoCat/Models/Vehicle.swift b/AutoCat/Models/Vehicle.swift index 9392aa6..23e716f 100644 --- a/AutoCat/Models/Vehicle.swift +++ b/AutoCat/Models/Vehicle.swift @@ -18,7 +18,7 @@ class VehicleModel: Object, Decodable { class VehicleEngine: Object, Decodable { @objc dynamic var number: String? - @objc dynamic var volume: Int = 0 + var volume: RealmOptional = RealmOptional(0) @objc dynamic var powerHp: Float = 0 @objc dynamic var powerKw: Float = 0 @objc dynamic var fuelType: String? diff --git a/AutoCat/Utils/Constants.swift b/AutoCat/Utils/Constants.swift index fd8bd02..34e7169 100644 --- a/AutoCat/Utils/Constants.swift +++ b/AutoCat/Utils/Constants.swift @@ -3,9 +3,9 @@ import Foundation enum Constants { static var baseUrl: String { #if DEBUG - //return "http://127.0.0.1:3000/" + return "http://127.0.0.1:3000/" //return "http://192.168.1.67:3000/" - return "https://vps.aliencat.pro:8443/" + //return "https://vps.aliencat.pro:8443/" #else return "https://vps.aliencat.pro:8443/" #endif diff --git a/AutoCat/Utils/RxRealmDataSource.swift b/AutoCat/Utils/RxRealmDataSource.swift index 93b1b41..bb05eb3 100644 --- a/AutoCat/Utils/RxRealmDataSource.swift +++ b/AutoCat/Utils/RxRealmDataSource.swift @@ -23,6 +23,7 @@ class RealmSectionedDataSource: NSObject, UITableViewDataSource where self.sections = self.data.groupedByDate() self.tv.reloadData() case .update(_, let deletions, let insertions, let modifications): + print("Deletions: \(deletions.count), Insertions: \(insertions.count), Modifications: \(modifications.count)") let newSections = self.data.groupedByDate() let changeset = StagedChangeset(source: self.sections, target: newSections, section: 0) @@ -32,7 +33,10 @@ class RealmSectionedDataSource: NSObject, UITableViewDataSource where self.tv.insertRows(at: insertions.map(self.indexPath), with: .automatic) self.tv.reloadRows(at: modifications.map(self.indexPath), with: .automatic) + print("Changesets count: \(changeset.count)") if let firstChangeset = changeset.first { + print("Deletions: \(firstChangeset.elementDeleted.map { $0.element })") + print("Insertions: \(firstChangeset.elementInserted.map { $0.element })") self.tv.deleteSections(IndexSet(firstChangeset.elementDeleted.map { $0.element }), with: .automatic) self.tv.insertSections(IndexSet(firstChangeset.elementInserted.map { $0.element }), with: .automatic) }