Skip to content

Commit a716c9b

Browse files
authored
Simplify Reader post menu (#25402)
1 parent c177d84 commit a716c9b

1 file changed

Lines changed: 9 additions & 30 deletions

File tree

WordPress/Classes/ViewRelated/Reader/Controllers/ReaderPostActions/ReaderPostMenu.swift

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,16 @@ struct ReaderPostMenu {
3333
}
3434

3535
private func makeBlogSection() -> UIMenu {
36-
var actions = [makeBlogMenu()]
36+
var actions = [viewBlog]
3737
if !post.isFollowing {
3838
actions.append(subscribe)
39+
} else {
40+
actions.append(ubsubscribe)
3941
}
42+
// return UIMenu(title: post.blogNameForDisplay() ?? "", options: [.displayInline], children: actions)
4043
return UIMenu(options: [.displayInline], children: actions)
4144
}
4245

43-
private func makeBlogMenu() -> UIMenuElement {
44-
var actions: [UIAction] = [goToBlog]
45-
if let siteURL = post.blogURL.flatMap(URL.init) {
46-
actions.append(viewBlogInBrowser(siteURL: siteURL))
47-
}
48-
if post.isFollowing {
49-
if let siteID = post.siteID?.intValue {
50-
actions.append(manageNotifications(for: siteID))
51-
}
52-
actions += [ubsubscribe]
53-
}
54-
return UIMenu(title: post.blogNameForDisplay() ?? Strings.blogDetails, children: actions)
55-
}
56-
5746
// MARK: Actions
5847

5948
private var share: UIAction {
@@ -84,11 +73,11 @@ struct ReaderPostMenu {
8473
}
8574
}
8675

87-
private var goToBlog: UIAction {
88-
UIAction(Strings.goToBlog, systemImage: "chevron.forward") {
76+
private var viewBlog: UIAction {
77+
UIAction(title: Strings.viewBlog, subtitle: post.blogNameForDisplay() ?? "", image: UIImage(systemName: "person")) {_ in
8978
guard let viewController else { return }
9079
ReaderHeaderAction().execute(post: post, origin: viewController)
91-
track(.goToBlog)
80+
track(.viewBlog)
9281
}
9382
}
9483

@@ -99,14 +88,6 @@ struct ReaderPostMenu {
9988
}
10089
}
10190

102-
private func viewBlogInBrowser(siteURL: URL) -> UIAction {
103-
return UIAction(Strings.viewInBrowser, systemImage: "safari") {
104-
let safariVC = SFSafariViewController(url: siteURL)
105-
viewController?.present(safariVC, animated: true)
106-
track(.viewBlogInBrowser)
107-
}
108-
}
109-
11091
private var ubsubscribe: UIAction {
11192
UIAction(SharedStrings.Reader.unsubscribe, systemImage: "minus.circle", attributes: [.destructive]) {
11293
ReaderSubscriptionHelper().toggleSiteSubscription(forPost: post)
@@ -235,8 +216,7 @@ private enum ReaderPostMenuAnalyticsButton: String {
235216
case share = "share"
236217
case viewPostInBrowser = "view_in_browser"
237218
case copyPostLink = "copy_post_link"
238-
case goToBlog = "blog_open"
239-
case viewBlogInBrowser = "blog_view_in_browser"
219+
case viewBlog = "blog_open"
240220
case subscribe = "blog_subscribe"
241221
case unsubscribe = "blog_unsubscribe"
242222
case manageNotifications = "blog_manage_notifications"
@@ -253,9 +233,8 @@ private enum ReaderPostMenuAnalyticsButton: String {
253233
private enum Strings {
254234
static let viewInBrowser = NSLocalizedString("reader.postContextMenu.viewInBrowser", value: "View in Browser", comment: "Context menu action")
255235
static let blockOrReport = NSLocalizedString("reader.postContextMenu.blockOrReportMenu", value: "Block or Report", comment: "Context menu action")
256-
static let goToBlog = NSLocalizedString("reader.postContextMenu.showBlog", value: "Go to Blog", comment: "Context menu action")
236+
static let viewBlog = NSLocalizedString("reader.postContextMenu.viewSite", value: "View Site", comment: "Context menu action")
257237
static let manageNotifications = NSLocalizedString("reader.postContextMenu.manageNotifications", value: "Manage Notifications", comment: "Context menu action")
258-
static let blogDetails = NSLocalizedString("reader.postContextMenu.blogDetails", value: "Blog Details", comment: "Context menu action (placeholder value when blog name not available – should never happen)")
259238
static let blockSite = NSLocalizedString("reader.postContextMenu.blockSite", value: "Block Site", comment: "Context menu action")
260239
static let blockUser = NSLocalizedString("reader.postContextMenu.blockUser", value: "Block User", comment: "Context menu action")
261240
static let reportPost = NSLocalizedString("reader.postContextMenu.reportPost", value: "Report Post", comment: "Context menu action")

0 commit comments

Comments
 (0)