From 40a742139b21c72d5c161256921801262c1878c0 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 27 Jun 2020 13:13:04 -0400 Subject: [PATCH] Fix menu state getting out of sync with bookmarked/muted state --- Tusker/Views/Status/BaseStatusTableViewCell.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index f8d8c61c..affc26e4 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -87,6 +87,10 @@ class BaseStatusTableViewCell: UITableViewCell { accessibilityElements = [displayNameLabel!, contentWarningLabel!, collapseButton!, contentTextView!, attachmentsView!] attachmentsView.isAccessibilityElement = true + if #available(iOS 14.0, *) { + moreButton.showsMenuAsPrimaryAction = true + } + NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil) } @@ -178,11 +182,6 @@ class BaseStatusTableViewCell: UITableViewCell { collapsible = state.collapsible! setCollapsed(state.collapsed!, animated: false) } - - if #available(iOS 14.0, *) { - moreButton.showsMenuAsPrimaryAction = true - moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: actionsForStatus(statusID: statusID, sourceView: moreButton)) - } } func updateStatusState(status: StatusMO) { @@ -199,6 +198,11 @@ class BaseStatusTableViewCell: UITableViewCell { } else { reblogButton.accessibilityLabel = NSLocalizedString("Reblog", comment: "reblog button accessibility label") } + + if #available(iOS 14.0, *) { + // keep menu in sync with changed states e.g. bookmarked, muted + moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: actionsForStatus(statusID: statusID, sourceView: moreButton)) + } } func updateUI(account: AccountMO) {