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.
This commit is contained in:
parent
66fe861442
commit
08c84688cf
|
@ -51,7 +51,7 @@ public extension InstanceSelector {
|
||||||
public let description: String
|
public let description: String
|
||||||
public let proxiedThumbnailURL: URL
|
public let proxiedThumbnailURL: URL
|
||||||
public let language: String
|
public let language: String
|
||||||
public let category: Category
|
public let category: String
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case domain
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class InstanceTableViewCell: UITableViewCell {
|
||||||
self.instance = nil
|
self.instance = nil
|
||||||
|
|
||||||
domainLabel.text = instance.domain
|
domainLabel.text = instance.domain
|
||||||
adultLabel.isHidden = instance.category != .adult
|
adultLabel.isHidden = instance.category != "adult"
|
||||||
descriptionTextView.setTextFromHtml(instance.description)
|
descriptionTextView.setTextFromHtml(instance.description)
|
||||||
updateThumbnail(url: instance.proxiedThumbnailURL)
|
updateThumbnail(url: instance.proxiedThumbnailURL)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue