From 79f44c9b5899cc618d7e285cd9bd128264a5bfbf Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 18 Jan 2020 19:49:10 -0500 Subject: [PATCH] Change recommended instance selector to store categories as strings instead of enum Additional categories can be added, which would cause a crash when decoding. As the category isn't used for anything, storing it as an enum value is not necessary. --- Pachyderm/Utilities/InstanceSelector.swift | 19 +------------------ .../Instance Cell/InstanceTableViewCell.swift | 2 +- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/Pachyderm/Utilities/InstanceSelector.swift b/Pachyderm/Utilities/InstanceSelector.swift index e0341f45..dd2ce064 100644 --- a/Pachyderm/Utilities/InstanceSelector.swift +++ b/Pachyderm/Utilities/InstanceSelector.swift @@ -51,7 +51,7 @@ public extension InstanceSelector { public let description: String public let proxiedThumbnailURL: URL public let language: String - public let category: Category + public let category: String enum CodingKeys: String, CodingKey { case domain @@ -62,20 +62,3 @@ public extension InstanceSelector { } } } - -public extension InstanceSelector { - enum Category: String, Codable { - // source: https://source.joinmastodon.org/mastodon/joinmastodon/blob/master/src/Wizard.js#L108 - case general - case regional - case art - case journalism - case activism - case lgbt - case games - case tech - case adult - case furry - case food - } -} diff --git a/Tusker/Views/Instance Cell/InstanceTableViewCell.swift b/Tusker/Views/Instance Cell/InstanceTableViewCell.swift index 920e068f..161015b3 100644 --- a/Tusker/Views/Instance Cell/InstanceTableViewCell.swift +++ b/Tusker/Views/Instance Cell/InstanceTableViewCell.swift @@ -36,7 +36,7 @@ class InstanceTableViewCell: UITableViewCell { self.instance = nil domainLabel.text = instance.domain - adultLabel.isHidden = instance.category != .adult + adultLabel.isHidden = instance.category != "adult" descriptionTextView.setTextFromHtml(instance.description) updateThumbnail(url: instance.proxiedThumbnailURL) }