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

View File

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