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
|
import Foundation
|
||||||
|
|
||||||
enum PostType: String, Decodable {
|
enum PostType: String, Decodable {
|
||||||
case picture
|
case text, picture
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Media: Decodable, Identifiable {
|
struct Media: Decodable, Identifiable {
|
||||||
|
|
|
@ -38,16 +38,18 @@ struct PostView: View {
|
||||||
|
|
||||||
VStack {
|
VStack {
|
||||||
ForEach(post.media) { media in
|
ForEach(post.media) { media in
|
||||||
VStack {
|
if !media.url.isEmpty {
|
||||||
RemoteImage(type: .url(URL(string: media.url.encodeUrl()!)!), errorView: { error in
|
VStack {
|
||||||
Text(error.localizedDescription)
|
RemoteImage(type: .url(URL(string: media.url.encodeUrl()!)!), errorView: { error in
|
||||||
}, imageView: { image in
|
Text(error.localizedDescription)
|
||||||
image
|
}, imageView: { image in
|
||||||
.resizable()
|
image
|
||||||
.aspectRatio(contentMode: .fit)
|
.resizable()
|
||||||
}, loadingView: {
|
.aspectRatio(contentMode: .fit)
|
||||||
Text("Loading...")
|
}, loadingView: {
|
||||||
})
|
Text("Loading...")
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue