resolving merge conflict

This commit is contained in:
Selim Mustafaev 2021-04-28 00:30:15 +03:00
parent 36958b4b93
commit ba0ebedc59
2 changed files with 8 additions and 15 deletions

View File

@ -345,12 +345,9 @@ class EventsController: UIViewController, UITableViewDataSource, UITableViewDele
func update(vehicle: Vehicle) -> Bool {
do {
if let realm = self.vehicle?.realm {
try ExceptionCatcher.catch {
try realm.write {
do {
try ExceptionCatcher.catch { realm.add(vehicle, update: .all) }
}
catch {
self.showAlert(title: "Error updating vehicle", message: error.localizedDescription)
realm.add(vehicle, update: .all)
}
}
} else {
@ -361,7 +358,8 @@ class EventsController: UIViewController, UITableViewDataSource, UITableViewDele
HUD.hide()
return true
} catch {
HUD.show(error: error)
HUD.hide()
self.show(error: error)
print(error)
return false
}

View File

@ -162,13 +162,8 @@ class SearchController: UIViewController, UISearchResultsUpdating, UITableViewDe
do {
let realm = try Realm()
if realm.object(ofType: Vehicle.self, forPrimaryKey: vehicle.getNumber()) != nil {
try? realm.write {
do {
try ExceptionCatcher.catch { realm.add(newVehicle, update: .all) }
}
catch {
self.showAlert(title: "Error updating vehicle", message: error.localizedDescription)
}
try realm.write {
realm.add(newVehicle, update: .all)
}
}
} catch {
@ -176,7 +171,7 @@ class SearchController: UIViewController, UISearchResultsUpdating, UITableViewDe
self.show(error: error)
}
let frozenVehicle = newVehicle.freeze()
let frozenVehicle = newVehicle.realm != nil ? newVehicle.freeze() : newVehicle
self.datasource.set(item: frozenVehicle, at: indexPath)
self.updateDetailController(with: frozenVehicle)
} onError: { err in