Use short descriptions in instance selector when available

This commit is contained in:
Shadowfacts 2022-10-31 17:35:50 -04:00
parent b755607895
commit c7e39cb041
2 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,7 @@ public class Instance: Decodable {
public let uri: String public let uri: String
public let title: String public let title: String
public let description: String public let description: String
public let shortDescription: String?
public let email: String? public let email: String?
public let version: String public let version: String
public let urls: [String: URL] public let urls: [String: URL]
@ -40,6 +41,7 @@ public class Instance: Decodable {
self.uri = try container.decode(String.self, forKey: .uri) self.uri = try container.decode(String.self, forKey: .uri)
self.title = try container.decode(String.self, forKey: .title) self.title = try container.decode(String.self, forKey: .title)
self.description = try container.decode(String.self, forKey: .description) 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.email = try container.decodeIfPresent(String.self, forKey: .email)
self.version = try container.decode(String.self, forKey: .version) self.version = try container.decode(String.self, forKey: .version)
if let urls = try? container.decodeIfPresent([String: URL].self, forKey: .urls) { if let urls = try? container.decodeIfPresent([String: URL].self, forKey: .urls) {
@ -72,6 +74,7 @@ public class Instance: Decodable {
case uri case uri
case title case title
case description case description
case shortDescription = "short_description"
case email case email
case version case version
case urls case urls

View File

@ -48,7 +48,7 @@ class InstanceTableViewCell: UITableViewCell {
domainLabel.text = URLComponents(string: instance.uri)?.host ?? instance.uri domainLabel.text = URLComponents(string: instance.uri)?.host ?? instance.uri
adultLabel.isHidden = true adultLabel.isHidden = true
descriptionTextView.setTextFromHtml(instance.description) descriptionTextView.setTextFromHtml(instance.shortDescription ?? instance.description)
if let thumbnail = instance.thumbnail { if let thumbnail = instance.thumbnail {
updateThumbnail(url: thumbnail) updateThumbnail(url: thumbnail)