From c7e39cb041042c6b0201cb7367d97ce01e308eca Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 31 Oct 2022 17:35:50 -0400 Subject: [PATCH] Use short descriptions in instance selector when available --- Pachyderm/Sources/Pachyderm/Model/Instance.swift | 3 +++ Tusker/Views/Instance Cell/InstanceTableViewCell.swift | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Pachyderm/Sources/Pachyderm/Model/Instance.swift b/Pachyderm/Sources/Pachyderm/Model/Instance.swift index c41835d1..407db5c3 100644 --- a/Pachyderm/Sources/Pachyderm/Model/Instance.swift +++ b/Pachyderm/Sources/Pachyderm/Model/Instance.swift @@ -12,6 +12,7 @@ public class Instance: Decodable { public let uri: String public let title: String public let description: String + public let shortDescription: String? public let email: String? public let version: String public let urls: [String: URL] @@ -40,6 +41,7 @@ public class Instance: Decodable { self.uri = try container.decode(String.self, forKey: .uri) self.title = try container.decode(String.self, forKey: .title) self.description = try container.decode(String.self, forKey: .description) + self.shortDescription = try container.decodeIfPresent(String.self, forKey: .shortDescription) self.email = try container.decodeIfPresent(String.self, forKey: .email) self.version = try container.decode(String.self, forKey: .version) if let urls = try? container.decodeIfPresent([String: URL].self, forKey: .urls) { @@ -72,6 +74,7 @@ public class Instance: Decodable { case uri case title case description + case shortDescription = "short_description" case email case version case urls diff --git a/Tusker/Views/Instance Cell/InstanceTableViewCell.swift b/Tusker/Views/Instance Cell/InstanceTableViewCell.swift index f2a77e72..c672dc75 100644 --- a/Tusker/Views/Instance Cell/InstanceTableViewCell.swift +++ b/Tusker/Views/Instance Cell/InstanceTableViewCell.swift @@ -48,7 +48,7 @@ class InstanceTableViewCell: UITableViewCell { domainLabel.text = URLComponents(string: instance.uri)?.host ?? instance.uri adultLabel.isHidden = true - descriptionTextView.setTextFromHtml(instance.description) + descriptionTextView.setTextFromHtml(instance.shortDescription ?? instance.description) if let thumbnail = instance.thumbnail { updateThumbnail(url: thumbnail)