Don't show reblog swipe action when reblogging is forbidden

Closes #313
This commit is contained in:
Shadowfacts 2022-12-17 13:09:33 -05:00
parent 97a2278634
commit 01467574d0
3 changed files with 12 additions and 1 deletions

View File

@ -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"

View File

@ -822,6 +822,10 @@ extension TimelineStatusCollectionViewCell: StatusSwipeActionContainer {
var navigationDelegate: TuskerNavigationDelegate { delegate! }
var toastableViewController: ToastableViewController? { delegate }
var canReblog: Bool {
reblogButton.isEnabled
}
func performReplyAction() {
self.replyPressed()
}

View File

@ -445,6 +445,10 @@ extension TimelineStatusTableViewCell: StatusSwipeActionContainer {
var navigationDelegate: TuskerNavigationDelegate { delegate! }
var toastableViewController: ToastableViewController? { delegate }
var canReblog: Bool {
reblogButton.isEnabled
}
func performReplyAction() {
self.replyPressed()
}