1
Fork 0

Decode text posts, and don't load empty media urls

This commit is contained in:
redstrate 2020-06-04 06:03:09 -04:00
parent e217fc6215
commit 9e25686cd6
2 changed files with 13 additions and 11 deletions

View file

@ -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 {

View file

@ -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...")
})
}
} }
} }
} }