Cleanup unneccessary error handling in the updatePasswordImage function
This commit is contained in:
parent
f0eb9c47ed
commit
9a3131943f
1 changed files with 8 additions and 19 deletions
|
|
@ -322,27 +322,16 @@ class PasswordDetailTableViewController: UITableViewController, UIGestureRecogni
|
|||
newUrlString = "https://\(urlString)"
|
||||
}
|
||||
|
||||
guard let url = URL(string: newUrlString) else {
|
||||
return
|
||||
}
|
||||
|
||||
do {
|
||||
try FavIcon.downloadPreferred(url) { [weak self] result in
|
||||
switch result {
|
||||
case .success(let image):
|
||||
let indexPath = IndexPath(row: 0, section: 0)
|
||||
self?.passwordImage = image
|
||||
self?.tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
|
||||
let imageData = UIImageJPEGRepresentation(image, 1)
|
||||
if let entity = self?.passwordEntity {
|
||||
self?.passwordStore.updateImage(passwordEntity: entity, image: imageData)
|
||||
}
|
||||
case .failure(let error):
|
||||
print(error)
|
||||
try? FavIcon.downloadPreferred(newUrlString) { [weak self] result in
|
||||
if case let .success(image) = result {
|
||||
let indexPath = IndexPath(row: 0, section: 0)
|
||||
self?.passwordImage = image
|
||||
self?.tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.automatic)
|
||||
let imageData = UIImageJPEGRepresentation(image, 1)
|
||||
if let entity = self?.passwordEntity {
|
||||
self?.passwordStore.updateImage(passwordEntity: entity, image: imageData)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue