Preserving events from unrecognised plate numbers

This commit is contained in:
Selim Mustafaev 2022-03-08 22:16:22 +03:00
parent fc20956e24
commit 3dfef5fccc
3 changed files with 20 additions and 4 deletions

View File

@ -1080,7 +1080,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 83;
CURRENT_PROJECT_VERSION = 86;
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 = 83;
CURRENT_PROJECT_VERSION = 86;
DEVELOPMENT_TEAM = 46DTTB8X4S;
INFOPLIST_FILE = AutoCat/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;

View File

@ -213,8 +213,18 @@ class CheckController: UIViewController, UITableViewDelegate, UITextFieldDelegat
self.number.text = nil
self.check.isEnabled = false
var events: [VehicleEvent] = []
do {
let realm = try Realm()
if let dbVehicle = realm.object(ofType: Vehicle.self, forPrimaryKey: numberNormalized), dbVehicle.unrecognized {
events.append(contentsOf: dbVehicle.events)
}
} catch {
print(error)
}
HUD.show(.progress)
self.check(number: numberNormalized, action: .receiveAndSend, notes: [], events: []).subscribe { (vehicle, errors) in
self.check(number: numberNormalized, action: .receiveAndSend, notes: [], events: events).subscribe { (vehicle, errors) in
if !vehicle.unrecognized {
self.updateDetailController(with: vehicle)
}

View File

@ -19,7 +19,13 @@ extension MKMapView {
diagonal = 1000
}
let region = MKCoordinateRegion(center: center, latitudinalMeters: diagonal, longitudinalMeters: diagonal)
var region = MKCoordinateRegion(center: center, latitudinalMeters: diagonal, longitudinalMeters: diagonal)
if region.span.latitudeDelta > 180 || region.span.longitudeDelta > 360 {
region = MKCoordinateRegion(center: .init(latitude: 0, longitude: 0),
span: .init(latitudeDelta: 180, longitudeDelta: 360))
}
self.setRegion(region, animated: true)
}
}