From 01467574d0b26d81ccc3c72246ce27f14a25133f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 17 Dec 2022 13:09:33 -0500 Subject: [PATCH] Don't show reblog swipe action when reblogging is forbidden Closes #313 --- Tusker/Preferences/StatusSwipeAction.swift | 5 ++++- Tusker/Views/Status/TimelineStatusCollectionViewCell.swift | 4 ++++ Tusker/Views/Status/TimelineStatusTableViewCell.swift | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Tusker/Preferences/StatusSwipeAction.swift b/Tusker/Preferences/StatusSwipeAction.swift index f6cccb8d..03a7d701 100644 --- a/Tusker/Preferences/StatusSwipeAction.swift +++ b/Tusker/Preferences/StatusSwipeAction.swift @@ -74,6 +74,8 @@ protocol StatusSwipeActionContainer: UIView { var navigationDelegate: any TuskerNavigationDelegate { get } var toastableViewController: ToastableViewController? { get } + var canReblog: Bool { get } + // necessary b/c the reblog-handling logic only exists in the cells func performReplyAction() } @@ -108,7 +110,8 @@ private func createFavoriteAction(status: StatusMO, container: StatusSwipeAction } private func createReblogAction(status: StatusMO, container: StatusSwipeActionContainer) -> UIContextualAction? { - guard container.mastodonController.loggedIn else { + guard container.mastodonController.loggedIn, + container.canReblog else { return nil } let title = status.reblogged ? "Unreblog" : "Reblog" diff --git a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift index e34ec77b..462918f4 100644 --- a/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusCollectionViewCell.swift @@ -822,6 +822,10 @@ extension TimelineStatusCollectionViewCell: StatusSwipeActionContainer { var navigationDelegate: TuskerNavigationDelegate { delegate! } var toastableViewController: ToastableViewController? { delegate } + var canReblog: Bool { + reblogButton.isEnabled + } + func performReplyAction() { self.replyPressed() } diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index fcd4d81d..71fd77ee 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -445,6 +445,10 @@ extension TimelineStatusTableViewCell: StatusSwipeActionContainer { var navigationDelegate: TuskerNavigationDelegate { delegate! } var toastableViewController: ToastableViewController? { delegate } + var canReblog: Bool { + reblogButton.isEnabled + } + func performReplyAction() { self.replyPressed() }