fix: remove ActionToolbarContainer.moreButtonDidPressed
This commit is contained in:
parent
8011298571
commit
b8f3f4c886
|
@ -780,7 +780,8 @@ extension StatusSection {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let author = status.authorForUserProvider
|
let author = status.authorForUserProvider
|
||||||
let canReport = authenticationBox.userID != author.id
|
let isMyself = authenticationBox.userID == author.id
|
||||||
|
let canReport = !isMyself
|
||||||
let isInSameDomain = authenticationBox.domain == author.domainFromAcct
|
let isInSameDomain = authenticationBox.domain == author.domainFromAcct
|
||||||
let isMuting = (author.mutingBy ?? Set()).map(\.id).contains(authenticationBox.userID)
|
let isMuting = (author.mutingBy ?? Set()).map(\.id).contains(authenticationBox.userID)
|
||||||
let isBlocking = (author.blockingBy ?? Set()).map(\.id).contains(authenticationBox.userID)
|
let isBlocking = (author.blockingBy ?? Set()).map(\.id).contains(authenticationBox.userID)
|
||||||
|
@ -788,9 +789,9 @@ extension StatusSection {
|
||||||
cell.statusView.actionToolbarContainer.moreButton.showsMenuAsPrimaryAction = true
|
cell.statusView.actionToolbarContainer.moreButton.showsMenuAsPrimaryAction = true
|
||||||
cell.statusView.actionToolbarContainer.moreButton.menu = UserProviderFacade.createProfileActionMenu(
|
cell.statusView.actionToolbarContainer.moreButton.menu = UserProviderFacade.createProfileActionMenu(
|
||||||
for: author,
|
for: author,
|
||||||
|
isMyself: isMyself,
|
||||||
isMuting: isMuting,
|
isMuting: isMuting,
|
||||||
isBlocking: isBlocking,
|
isBlocking: isBlocking,
|
||||||
canReport: canReport,
|
|
||||||
isInSameDomain: isInSameDomain,
|
isInSameDomain: isInSameDomain,
|
||||||
isDomainBlocking: isDomainBlocking,
|
isDomainBlocking: isDomainBlocking,
|
||||||
provider: userProvider,
|
provider: userProvider,
|
||||||
|
|
|
@ -146,9 +146,9 @@ extension UserProviderFacade {
|
||||||
extension UserProviderFacade {
|
extension UserProviderFacade {
|
||||||
static func createProfileActionMenu(
|
static func createProfileActionMenu(
|
||||||
for mastodonUser: MastodonUser,
|
for mastodonUser: MastodonUser,
|
||||||
|
isMyself: Bool,
|
||||||
isMuting: Bool,
|
isMuting: Bool,
|
||||||
isBlocking: Bool,
|
isBlocking: Bool,
|
||||||
canReport: Bool,
|
|
||||||
isInSameDomain: Bool,
|
isInSameDomain: Bool,
|
||||||
isDomainBlocking: Bool,
|
isDomainBlocking: Bool,
|
||||||
provider: UserProvider,
|
provider: UserProvider,
|
||||||
|
@ -161,6 +161,7 @@ extension UserProviderFacade {
|
||||||
var children: [UIMenuElement] = []
|
var children: [UIMenuElement] = []
|
||||||
let name = mastodonUser.displayNameWithFallback
|
let name = mastodonUser.displayNameWithFallback
|
||||||
|
|
||||||
|
if !isMyself {
|
||||||
// mute
|
// mute
|
||||||
let muteAction = UIAction(
|
let muteAction = UIAction(
|
||||||
title: isMuting ? L10n.Common.Controls.Firendship.unmuteUser(name) : L10n.Common.Controls.Firendship.mute,
|
title: isMuting ? L10n.Common.Controls.Firendship.unmuteUser(name) : L10n.Common.Controls.Firendship.mute,
|
||||||
|
@ -188,7 +189,9 @@ extension UserProviderFacade {
|
||||||
let muteMenu = UIMenu(title: L10n.Common.Controls.Firendship.muteUser(name), image: UIImage(systemName: "speaker.slash"), options: [], children: [muteAction])
|
let muteMenu = UIMenu(title: L10n.Common.Controls.Firendship.muteUser(name), image: UIImage(systemName: "speaker.slash"), options: [], children: [muteAction])
|
||||||
children.append(muteMenu)
|
children.append(muteMenu)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isMyself {
|
||||||
// block
|
// block
|
||||||
let blockAction = UIAction(
|
let blockAction = UIAction(
|
||||||
title: isBlocking ? L10n.Common.Controls.Firendship.unblockUser(name) : L10n.Common.Controls.Firendship.block,
|
title: isBlocking ? L10n.Common.Controls.Firendship.unblockUser(name) : L10n.Common.Controls.Firendship.block,
|
||||||
|
@ -216,7 +219,9 @@ extension UserProviderFacade {
|
||||||
let blockMenu = UIMenu(title: L10n.Common.Controls.Firendship.blockUser(name), image: UIImage(systemName: "hand.raised"), options: [], children: [blockAction])
|
let blockMenu = UIMenu(title: L10n.Common.Controls.Firendship.blockUser(name), image: UIImage(systemName: "hand.raised"), options: [], children: [blockAction])
|
||||||
children.append(blockMenu)
|
children.append(blockMenu)
|
||||||
}
|
}
|
||||||
if canReport {
|
}
|
||||||
|
|
||||||
|
if !isMyself {
|
||||||
let reportAction = UIAction(title: L10n.Common.Controls.Actions.reportUser(name), image: UIImage(systemName: "flag"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) { [weak provider] _ in
|
let reportAction = UIAction(title: L10n.Common.Controls.Actions.reportUser(name), image: UIImage(systemName: "flag"), identifier: nil, discoverabilityTitle: nil, attributes: [], state: .off) { [weak provider] _ in
|
||||||
guard let provider = provider else { return }
|
guard let provider = provider else { return }
|
||||||
guard let authenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else {
|
guard let authenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else {
|
||||||
|
|
|
@ -384,17 +384,23 @@ extension ProfileViewController {
|
||||||
self.moreMenuBarButtonItem.menu = nil
|
self.moreMenuBarButtonItem.menu = nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
guard let currentMastodonUser = self.viewModel.currentMastodonUser.value else {
|
||||||
|
self.moreMenuBarButtonItem.menu = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
guard let currentDomain = self.viewModel.domain.value else { return }
|
guard let currentDomain = self.viewModel.domain.value else { return }
|
||||||
let isMuting = relationshipActionOptionSet.contains(.muting)
|
let isMuting = relationshipActionOptionSet.contains(.muting)
|
||||||
let isBlocking = relationshipActionOptionSet.contains(.blocking)
|
let isBlocking = relationshipActionOptionSet.contains(.blocking)
|
||||||
let isDomainBlocking = domains.contains(mastodonUser.domainFromAcct)
|
let isDomainBlocking = domains.contains(mastodonUser.domainFromAcct)
|
||||||
let needsShareAction = self.viewModel.isMeBarButtonItemsHidden.value
|
let needsShareAction = self.viewModel.isMeBarButtonItemsHidden.value
|
||||||
let isInSameDomain = mastodonUser.domainFromAcct == currentDomain
|
let isInSameDomain = mastodonUser.domainFromAcct == currentDomain
|
||||||
|
let isMyself = currentMastodonUser.id == mastodonUser.id
|
||||||
|
|
||||||
self.moreMenuBarButtonItem.menu = UserProviderFacade.createProfileActionMenu(
|
self.moreMenuBarButtonItem.menu = UserProviderFacade.createProfileActionMenu(
|
||||||
for: mastodonUser,
|
for: mastodonUser,
|
||||||
|
isMyself: isMyself,
|
||||||
isMuting: isMuting,
|
isMuting: isMuting,
|
||||||
isBlocking: isBlocking,
|
isBlocking: isBlocking,
|
||||||
canReport: true,
|
|
||||||
isInSameDomain: isInSameDomain,
|
isInSameDomain: isInSameDomain,
|
||||||
isDomainBlocking: isDomainBlocking,
|
isDomainBlocking: isDomainBlocking,
|
||||||
provider: self,
|
provider: self,
|
||||||
|
|
|
@ -356,8 +356,4 @@ extension StatusTableViewCell: ActionToolbarContainerDelegate {
|
||||||
delegate?.statusTableViewCell(self, actionToolbarContainer: actionToolbarContainer, likeButtonDidPressed: sender)
|
delegate?.statusTableViewCell(self, actionToolbarContainer: actionToolbarContainer, likeButtonDidPressed: sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, moreButtonDidPressed sender: UIButton) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ protocol ActionToolbarContainerDelegate: class {
|
||||||
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, replayButtonDidPressed sender: UIButton)
|
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, replayButtonDidPressed sender: UIButton)
|
||||||
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, reblogButtonDidPressed sender: UIButton)
|
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, reblogButtonDidPressed sender: UIButton)
|
||||||
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, starButtonDidPressed sender: UIButton)
|
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, starButtonDidPressed sender: UIButton)
|
||||||
func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, moreButtonDidPressed sender: UIButton)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +62,6 @@ extension ActionToolbarContainer {
|
||||||
replyButton.addTarget(self, action: #selector(ActionToolbarContainer.replyButtonDidPressed(_:)), for: .touchUpInside)
|
replyButton.addTarget(self, action: #selector(ActionToolbarContainer.replyButtonDidPressed(_:)), for: .touchUpInside)
|
||||||
reblogButton.addTarget(self, action: #selector(ActionToolbarContainer.reblogButtonDidPressed(_:)), for: .touchUpInside)
|
reblogButton.addTarget(self, action: #selector(ActionToolbarContainer.reblogButtonDidPressed(_:)), for: .touchUpInside)
|
||||||
favoriteButton.addTarget(self, action: #selector(ActionToolbarContainer.favoriteButtonDidPressed(_:)), for: .touchUpInside)
|
favoriteButton.addTarget(self, action: #selector(ActionToolbarContainer.favoriteButtonDidPressed(_:)), for: .touchUpInside)
|
||||||
moreButton.addTarget(self, action: #selector(ActionToolbarContainer.moreButtonDidPressed(_:)), for: .touchUpInside)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -194,11 +192,6 @@ extension ActionToolbarContainer {
|
||||||
delegate?.actionToolbarContainer(self, starButtonDidPressed: sender)
|
delegate?.actionToolbarContainer(self, starButtonDidPressed: sender)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func moreButtonDidPressed(_ sender: UIButton) {
|
|
||||||
os_log("%{public}s[%{public}ld], %{public}s", ((#file as NSString).lastPathComponent), #line, #function)
|
|
||||||
delegate?.actionToolbarContainer(self, moreButtonDidPressed: sender)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
|
|
@ -62,6 +62,6 @@ protocol PutQuery: RequestQuery { }
|
||||||
protocol DeleteQuery: RequestQuery { }
|
protocol DeleteQuery: RequestQuery { }
|
||||||
|
|
||||||
extension DeleteQuery {
|
extension DeleteQuery {
|
||||||
// By default a `PostQuery` does not has query items
|
// By default a `DeleteQuery` does not has query items
|
||||||
var queryItems: [URLQueryItem]? { nil }
|
var queryItems: [URLQueryItem]? { nil }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue