From 9417872790a497f488cdbf7d5bbbb3a2683f201c Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 9 Jun 2021 17:10:44 -0400 Subject: [PATCH] Don't show Reply action in menu button on statuses --- Tusker/Screens/Utilities/Previewing.swift | 13 ++++++++----- Tusker/Views/Status/BaseStatusTableViewCell.swift | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index cd4f6fdd..c23c0882 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -133,7 +133,7 @@ extension MenuPreviewProvider { ] } - func actionsForStatus(_ status: StatusMO, sourceView: UIView?) -> [UIMenuElement] { + func actionsForStatus(_ status: StatusMO, sourceView: UIView?, includeReply: Bool = true) -> [UIMenuElement] { guard let mastodonController = mastodonController else { return [] } guard mastodonController.loggedIn else { @@ -150,10 +150,6 @@ extension MenuPreviewProvider { let muted = status.muted var actionsSection = [ - createAction(identifier: "reply", title: "Reply", systemImageName: "arrowshape.turn.up.left", handler: { [weak self] (_) in - guard let self = self else { return } - self.navigationDelegate?.compose(inReplyToID: status.id) - }), createAction(identifier: "bookmark", title: bookmarked ? "Unbookmark" : "Bookmark", systemImageName: bookmarked ? "bookmark.fill" : "bookmark", handler: { [weak self] (_) in guard let self = self else { return } let request = (bookmarked ? Status.unbookmark : Status.bookmark)(status.id) @@ -174,6 +170,13 @@ extension MenuPreviewProvider { }) ] + if includeReply { + actionsSection.insert(createAction(identifier: "reply", title: "Reply", systemImageName: "arrowshape.turn.up.left", handler: { [weak self] (_) in + guard let self = self else { return } + self.navigationDelegate?.compose(inReplyToID: status.id) + }), at: 0) + } + if mastodonController.account != nil && mastodonController.account.id == status.account.id { let pinned = status.pinned ?? false actionsSection.append(createAction(identifier: "pin", title: pinned ? "Unpin from Profile" : "Pin to Profile", systemImageName: pinned ? "pin.slash" : "pin", handler: { [weak self] (_) in diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index 2381d0bb..281d28df 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -210,7 +210,8 @@ class BaseStatusTableViewCell: UITableViewCell, MenuPreviewProvider { } // keep menu in sync with changed states e.g. bookmarked, muted - moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: actionsForStatus(status, sourceView: moreButton)) + // do not include reply action here, because the cell already contains a button for it + moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: actionsForStatus(status, sourceView: moreButton, includeReply: false)) pollView.isHidden = status.poll == nil pollView.mastodonController = mastodonController