Don't show duplicate actions in status cell more actions menu

This commit is contained in:
Shadowfacts 2022-11-23 11:47:00 -05:00
parent c2cb0a0c5a
commit 9f7d16a70e
3 changed files with 8 additions and 6 deletions

View File

@ -138,7 +138,7 @@ extension MenuActionProvider {
]
}
func actionsForStatus(_ status: StatusMO, sourceView: UIView?, includeReply: Bool = true) -> [UIMenuElement] {
func actionsForStatus(_ status: StatusMO, sourceView: UIView?, includeStatusButtonActions: Bool = true) -> [UIMenuElement] {
guard let mastodonController = mastodonController else { return [] }
guard let accountID = mastodonController.accountInfo?.id else {
@ -169,7 +169,8 @@ extension MenuActionProvider {
}),
]
if #available(iOS 16.0, *) {
if #available(iOS 16.0, *),
includeStatusButtonActions {
let favorited = status.favourited
// TODO: move this color into an asset catalog or something
var favImage = UIImage(systemName: favorited ? "star.fill" : "star")!
@ -200,7 +201,7 @@ extension MenuActionProvider {
var actionsSection: [UIAction] = []
if includeReply {
if includeStatusButtonActions {
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)
@ -278,8 +279,9 @@ extension MenuActionProvider {
addOpenInNewWindow(actions: &shareSection, activity: UserActivityManager.showConversationActivity(mainStatusID: status.id, accountID: accountID))
if #available(iOS 16.0, *) {
let toggleableAndActions = toggleableSection + actionsSection
return [
UIMenu(options: .displayInline, preferredElementSize: .medium, children: toggleableSection + actionsSection),
UIMenu(options: .displayInline, preferredElementSize: toggleableAndActions.count == 1 ? .large : .medium, children: toggleableAndActions),
UIMenu(options: .displayInline, children: shareSection),
]
} else {

View File

@ -209,7 +209,7 @@ class BaseStatusTableViewCell: UITableViewCell {
// keep menu in sync with changed states e.g. bookmarked, muted
// 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: delegate?.actionsForStatus(status, sourceView: moreButton, includeReply: false) ?? [])
moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: delegate?.actionsForStatus(status, sourceView: moreButton, includeStatusButtonActions: false) ?? [])
pollView.isHidden = status.poll == nil
pollView.mastodonController = mastodonController

View File

@ -195,7 +195,7 @@ extension StatusCollectionViewCell {
// keep menu in sync with changed states e.g. bookmarked, muted
// 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: delegate?.actionsForStatus(status, sourceView: moreButton, includeReply: false) ?? [])
moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: delegate?.actionsForStatus(status, sourceView: moreButton, includeStatusButtonActions: false) ?? [])
contentContainer.pollView.isHidden = status.poll == nil
contentContainer.pollView.mastodonController = mastodonController