Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Sources/WordPressData/Swift/ReaderSiteTopic+Lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import Foundation

public extension ReaderSiteTopic {

/// The preferred display title for the site.
/// Returns the site title if not empty, otherwise returns the site host, or "–" if unavailable.
var preferredDisplayTitle: String {
if !title.isEmpty {
return title
}
return URL(string: siteURL)?.host ?? "–"
}

/// Find a site topic by its site id
///
/// - Parameter siteID: The site id of the topic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct ReaderSidebarSubscriptionCell: View {
var body: some View {
HStack {
Label {
Text(site.title)
Text(site.preferredDisplayTitle)
} icon: {
ReaderSiteIconView(site: site, size: .small)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct ReaderSubscriptionCell: View {

VStack(alignment: .leading, spacing: 3) {
HStack(alignment: .firstTextBaseline, spacing: 8) {
Text(site.title)
Text(site.preferredDisplayTitle)
.font(.body.weight(.medium))
}
Text(details)
Expand Down