Decode text posts, and don't load empty media urls
This commit is contained in:
parent
e217fc6215
commit
9e25686cd6
2 changed files with 13 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
import Foundation
|
||||
|
||||
enum PostType: String, Decodable {
|
||||
case picture
|
||||
case text, picture
|
||||
}
|
||||
|
||||
struct Media: Decodable, Identifiable {
|
||||
|
|
|
@ -38,16 +38,18 @@ struct PostView: View {
|
|||
|
||||
VStack {
|
||||
ForEach(post.media) { media in
|
||||
VStack {
|
||||
RemoteImage(type: .url(URL(string: media.url.encodeUrl()!)!), errorView: { error in
|
||||
Text(error.localizedDescription)
|
||||
}, imageView: { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
}, loadingView: {
|
||||
Text("Loading...")
|
||||
})
|
||||
if !media.url.isEmpty {
|
||||
VStack {
|
||||
RemoteImage(type: .url(URL(string: media.url.encodeUrl()!)!), errorView: { error in
|
||||
Text(error.localizedDescription)
|
||||
}, imageView: { image in
|
||||
image
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
}, loadingView: {
|
||||
Text("Loading...")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue