From 9e25686cd6d2918b9060974d659f9a8e4b84f5e8 Mon Sep 17 00:00:00 2001 From: redstrate <54911369+redstrate@users.noreply.github.com> Date: Thu, 4 Jun 2020 06:03:09 -0400 Subject: [PATCH] Decode text posts, and don't load empty media urls --- MobileFort/MobileFort/Common.swift | 2 +- MobileFort/MobileFort/PostView.swift | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/MobileFort/MobileFort/Common.swift b/MobileFort/MobileFort/Common.swift index 3d1720a..ab4b036 100644 --- a/MobileFort/MobileFort/Common.swift +++ b/MobileFort/MobileFort/Common.swift @@ -1,7 +1,7 @@ import Foundation enum PostType: String, Decodable { - case picture + case text, picture } struct Media: Decodable, Identifiable { diff --git a/MobileFort/MobileFort/PostView.swift b/MobileFort/MobileFort/PostView.swift index 997d194..d32e302 100644 --- a/MobileFort/MobileFort/PostView.swift +++ b/MobileFort/MobileFort/PostView.swift @@ -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...") + }) + } } } }