Adopt new authors-API-change and add publisher
This commit is contained in:
parent
54986620e7
commit
b9fa20f083
@ -22,8 +22,10 @@ extension Mastodon.Entity {
|
||||
public let title: String
|
||||
public let description: String
|
||||
public let type: Type
|
||||
|
||||
|
||||
@available(*, deprecated, message: "Use authors-array. Kept for compatibility")
|
||||
public let authorName: String?
|
||||
@available(*, deprecated, message: "Use authors-array. Kept for compatibility")
|
||||
public let authorURL: String?
|
||||
public let providerName: String?
|
||||
public let providerURL: String?
|
||||
@ -33,7 +35,7 @@ extension Mastodon.Entity {
|
||||
public let image: String?
|
||||
public let embedURL: String?
|
||||
public let blurhash: String?
|
||||
public let authorAccount: Mastodon.Entity.Account?
|
||||
public let authors: [Mastodon.Entity.Card.Author]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case url
|
||||
@ -50,11 +52,19 @@ extension Mastodon.Entity {
|
||||
case image
|
||||
case embedURL = "embed_url"
|
||||
case blurhash
|
||||
case authorAccount = "author_account"
|
||||
case authors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Mastodon.Entity.Card {
|
||||
public struct Author: Codable, Sendable {
|
||||
public let name: String?
|
||||
public let url: String?
|
||||
public let account: Mastodon.Entity.Account?
|
||||
}
|
||||
}
|
||||
|
||||
extension Mastodon.Entity.Card {
|
||||
public enum `Type`: RawRepresentable, Codable, Sendable {
|
||||
case link
|
||||
|
@ -184,12 +184,13 @@ public final class StatusCardControl: UIControl {
|
||||
accessibilityLabel = title
|
||||
}
|
||||
|
||||
if let authorAccount = card.authorAccount {
|
||||
authorAccountButton.configuration?.title = authorAccount.displayName
|
||||
|
||||
if let author = card.authors?.first {
|
||||
authorAccountButton.configuration?.title = author.name ?? author.account?.displayName
|
||||
authorAccountButton.isHidden = false
|
||||
authorLabel.isHidden = true
|
||||
byLabel.isHidden = false
|
||||
mastodonLogoImageView.isHidden = false
|
||||
mastodonLogoImageView.isHidden = (author.account == nil)
|
||||
} else {
|
||||
if let authorName = card.authorName, authorName.isEmpty == false {
|
||||
authorLabel.text = "by \(authorName)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user