Skip to content

Commit 743265a

Browse files
authored
Add fallback for subscription title for JN sites (#25027)
1 parent 8873de6 commit 743265a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Sources/WordPressData/Swift/ReaderSiteTopic+Lookup.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ import Foundation
33

44
public extension ReaderSiteTopic {
55

6+
/// The preferred display title for the site.
7+
/// Returns the site title if not empty, otherwise returns the site host, or "–" if unavailable.
8+
var preferredDisplayTitle: String {
9+
if !title.isEmpty {
10+
return title
11+
}
12+
return URL(string: siteURL)?.host ?? ""
13+
}
14+
615
/// Find a site topic by its site id
716
///
817
/// - Parameter siteID: The site id of the topic

WordPress/Classes/ViewRelated/Reader/Sidebar/ReaderSidebarSubscriptionsSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ struct ReaderSidebarSubscriptionCell: View {
3636
var body: some View {
3737
HStack {
3838
Label {
39-
Text(site.title)
39+
Text(site.preferredDisplayTitle)
4040
} icon: {
4141
ReaderSiteIconView(site: site, size: .small)
4242
}

WordPress/Classes/ViewRelated/Reader/Subscriptions/ReaderSubscriptionCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct ReaderSubscriptionCell: View {
2727

2828
VStack(alignment: .leading, spacing: 3) {
2929
HStack(alignment: .firstTextBaseline, spacing: 8) {
30-
Text(site.title)
30+
Text(site.preferredDisplayTitle)
3131
.font(.body.weight(.medium))
3232
}
3333
Text(details)

0 commit comments

Comments
 (0)