corrected ordering of guard for thumbnail

This commit is contained in:
Stuart Breckenridge 2022-07-29 07:33:05 +08:00
parent 141ed4f915
commit 10a455399d
No known key found for this signature in database
GPG Key ID: 64DCE361D27B805B
1 changed files with 12 additions and 7 deletions

View File

@ -54,13 +54,18 @@ struct ArticleItemView: View {
}
func thumbnail(from path: String?) -> Image? {
guard let imagePath = path,
let url = URL(string: imagePath),
let data = try? Data(contentsOf: url),
let uiImage = UIImage(data: data) else {
return Image(uiImage: UIImage(systemName: "globe")!)
}
return Image(uiImage: uiImage)
guard let imagePath = path else {
return Image(uiImage: UIImage(systemName: "globe")!)
}
let url = URL(fileURLWithPath: imagePath)
guard let data = try? Data(contentsOf: url),
let uiImage = UIImage(data: data) else {
return Image(uiImage: UIImage(systemName: "globe")!)
}
return Image(uiImage: uiImage)
}
func pubDate(_ dateString: String) -> String {