diff --git a/Localization/app.json b/Localization/app.json index 28b95fa2c..fbc670da6 100644 --- a/Localization/app.json +++ b/Localization/app.json @@ -29,7 +29,7 @@ "confirm": "Sign Out" }, "block_domain": { - "message": "Are you really, really sure you want to block the entire %s ? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.", + "message": "Are you really, really sure you want to block the entire %s? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.", "block_entire_domain": "Block entire domain" }, "save_photo_failure": { diff --git a/Mastodon/Diffiable/Section/StatusSection.swift b/Mastodon/Diffiable/Section/StatusSection.swift index cb38ec8ab..3994229ee 100644 --- a/Mastodon/Diffiable/Section/StatusSection.swift +++ b/Mastodon/Diffiable/Section/StatusSection.swift @@ -780,7 +780,8 @@ extension StatusSection { return } 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 isMuting = (author.mutingBy ?? 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.menu = UserProviderFacade.createProfileActionMenu( for: author, + isMyself: isMyself, isMuting: isMuting, isBlocking: isBlocking, - canReport: canReport, isInSameDomain: isInSameDomain, isDomainBlocking: isDomainBlocking, provider: userProvider, diff --git a/Mastodon/Generated/Strings.swift b/Mastodon/Generated/Strings.swift index b12d78df8..4ec5e7037 100644 --- a/Mastodon/Generated/Strings.swift +++ b/Mastodon/Generated/Strings.swift @@ -16,7 +16,7 @@ internal enum L10n { internal enum BlockDomain { /// Block entire domain internal static let blockEntireDomain = L10n.tr("Localizable", "Common.Alerts.BlockDomain.BlockEntireDomain") - /// Are you really, really sure you want to block the entire %@ ? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed. + /// Are you really, really sure you want to block the entire %@? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed. internal static func message(_ p1: Any) -> String { return L10n.tr("Localizable", "Common.Alerts.BlockDomain.Message", String(describing: p1)) } diff --git a/Mastodon/Protocol/UserProvider/UserProviderFacade.swift b/Mastodon/Protocol/UserProvider/UserProviderFacade.swift index 2aeff0e09..9e20e414a 100644 --- a/Mastodon/Protocol/UserProvider/UserProviderFacade.swift +++ b/Mastodon/Protocol/UserProvider/UserProviderFacade.swift @@ -146,9 +146,9 @@ extension UserProviderFacade { extension UserProviderFacade { static func createProfileActionMenu( for mastodonUser: MastodonUser, + isMyself: Bool, isMuting: Bool, isBlocking: Bool, - canReport: Bool, isInSameDomain: Bool, isDomainBlocking: Bool, provider: UserProvider, @@ -161,62 +161,67 @@ extension UserProviderFacade { var children: [UIMenuElement] = [] let name = mastodonUser.displayNameWithFallback - // mute - let muteAction = UIAction( - title: isMuting ? L10n.Common.Controls.Firendship.unmuteUser(name) : L10n.Common.Controls.Firendship.mute, - image: isMuting ? UIImage(systemName: "speaker") : UIImage(systemName: "speaker.slash"), - discoverabilityTitle: isMuting ? nil : L10n.Common.Controls.Firendship.muteUser(name), - attributes: isMuting ? [] : .destructive, - state: .off - ) { [weak provider] _ in - guard let provider = provider else { return } + if !isMyself { + // mute + let muteAction = UIAction( + title: isMuting ? L10n.Common.Controls.Firendship.unmuteUser(name) : L10n.Common.Controls.Firendship.mute, + image: isMuting ? UIImage(systemName: "speaker") : UIImage(systemName: "speaker.slash"), + discoverabilityTitle: isMuting ? nil : L10n.Common.Controls.Firendship.muteUser(name), + attributes: isMuting ? [] : .destructive, + state: .off + ) { [weak provider] _ in + guard let provider = provider else { return } - UserProviderFacade.toggleUserMuteRelationship( - provider: provider, - cell: cell - ) - .sink { _ in - // do nothing - } receiveValue: { _ in - // do nothing + UserProviderFacade.toggleUserMuteRelationship( + provider: provider, + cell: cell + ) + .sink { _ in + // do nothing + } receiveValue: { _ in + // do nothing + } + .store(in: &provider.context.disposeBag) + } + if isMuting { + children.append(muteAction) + } else { + let muteMenu = UIMenu(title: L10n.Common.Controls.Firendship.muteUser(name), image: UIImage(systemName: "speaker.slash"), options: [], children: [muteAction]) + children.append(muteMenu) } - .store(in: &provider.context.disposeBag) - } - if isMuting { - children.append(muteAction) - } else { - let muteMenu = UIMenu(title: L10n.Common.Controls.Firendship.muteUser(name), image: UIImage(systemName: "speaker.slash"), options: [], children: [muteAction]) - children.append(muteMenu) } - // block - let blockAction = UIAction( - title: isBlocking ? L10n.Common.Controls.Firendship.unblockUser(name) : L10n.Common.Controls.Firendship.block, - image: isBlocking ? UIImage(systemName: "hand.raised.slash") : UIImage(systemName: "hand.raised"), - discoverabilityTitle: isBlocking ? nil : L10n.Common.Controls.Firendship.blockUser(name), - attributes: isBlocking ? [] : .destructive, - state: .off - ) { [weak provider] _ in - guard let provider = provider else { return } + if !isMyself { + // block + let blockAction = UIAction( + title: isBlocking ? L10n.Common.Controls.Firendship.unblockUser(name) : L10n.Common.Controls.Firendship.block, + image: isBlocking ? UIImage(systemName: "hand.raised.slash") : UIImage(systemName: "hand.raised"), + discoverabilityTitle: isBlocking ? nil : L10n.Common.Controls.Firendship.blockUser(name), + attributes: isBlocking ? [] : .destructive, + state: .off + ) { [weak provider] _ in + guard let provider = provider else { return } - UserProviderFacade.toggleUserBlockRelationship( - provider: provider, - cell: cell - ) - .sink { _ in - // do nothing - } receiveValue: { _ in - // do nothing + UserProviderFacade.toggleUserBlockRelationship( + provider: provider, + cell: cell + ) + .sink { _ in + // do nothing + } receiveValue: { _ in + // do nothing + } + .store(in: &provider.context.disposeBag) + } + if isBlocking { + children.append(blockAction) + } else { + let blockMenu = UIMenu(title: L10n.Common.Controls.Firendship.blockUser(name), image: UIImage(systemName: "hand.raised"), options: [], children: [blockAction]) + children.append(blockMenu) } - .store(in: &provider.context.disposeBag) } - if isBlocking { - children.append(blockAction) - } else { - let blockMenu = UIMenu(title: L10n.Common.Controls.Firendship.blockUser(name), image: UIImage(systemName: "hand.raised"), options: [], children: [blockAction]) - 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 guard let provider = provider else { return } guard let authenticationBox = provider.context.authenticationService.activeMastodonAuthenticationBox.value else { diff --git a/Mastodon/Resources/en.lproj/Localizable.strings b/Mastodon/Resources/en.lproj/Localizable.strings index e18674a7b..59f83a5cd 100644 --- a/Mastodon/Resources/en.lproj/Localizable.strings +++ b/Mastodon/Resources/en.lproj/Localizable.strings @@ -1,5 +1,5 @@ "Common.Alerts.BlockDomain.BlockEntireDomain" = "Block entire domain"; -"Common.Alerts.BlockDomain.Message" = "Are you really, really sure you want to block the entire %@ ? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed."; +"Common.Alerts.BlockDomain.Message" = "Are you really, really sure you want to block the entire %@? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed."; "Common.Alerts.Common.PleaseTryAgain" = "Please try again."; "Common.Alerts.Common.PleaseTryAgainLater" = "Please try again later."; "Common.Alerts.DiscardPostContent.Message" = "Confirm discard composed post content."; diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 521df753b..d186d13df 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -384,17 +384,23 @@ extension ProfileViewController { self.moreMenuBarButtonItem.menu = nil return } + guard let currentMastodonUser = self.viewModel.currentMastodonUser.value else { + self.moreMenuBarButtonItem.menu = nil + return + } guard let currentDomain = self.viewModel.domain.value else { return } let isMuting = relationshipActionOptionSet.contains(.muting) let isBlocking = relationshipActionOptionSet.contains(.blocking) let isDomainBlocking = domains.contains(mastodonUser.domainFromAcct) let needsShareAction = self.viewModel.isMeBarButtonItemsHidden.value let isInSameDomain = mastodonUser.domainFromAcct == currentDomain + let isMyself = currentMastodonUser.id == mastodonUser.id + self.moreMenuBarButtonItem.menu = UserProviderFacade.createProfileActionMenu( for: mastodonUser, + isMyself: isMyself, isMuting: isMuting, isBlocking: isBlocking, - canReport: true, isInSameDomain: isInSameDomain, isDomainBlocking: isDomainBlocking, provider: self, diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift index 4a897a349..462577a4b 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift @@ -356,8 +356,4 @@ extension StatusTableViewCell: ActionToolbarContainerDelegate { delegate?.statusTableViewCell(self, actionToolbarContainer: actionToolbarContainer, likeButtonDidPressed: sender) } - func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, moreButtonDidPressed sender: UIButton) { - - } - } diff --git a/Mastodon/Scene/Share/View/ToolBar/ActionToolBarContainer.swift b/Mastodon/Scene/Share/View/ToolBar/ActionToolBarContainer.swift index b777207d2..a2f57dee2 100644 --- a/Mastodon/Scene/Share/View/ToolBar/ActionToolBarContainer.swift +++ b/Mastodon/Scene/Share/View/ToolBar/ActionToolBarContainer.swift @@ -12,7 +12,6 @@ protocol ActionToolbarContainerDelegate: class { func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, replayButtonDidPressed sender: UIButton) func actionToolbarContainer(_ actionToolbarContainer: ActionToolbarContainer, reblogButtonDidPressed 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) reblogButton.addTarget(self, action: #selector(ActionToolbarContainer.reblogButtonDidPressed(_:)), 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) } - @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 diff --git a/MastodonSDK/Sources/MastodonSDK/Query/Query.swift b/MastodonSDK/Sources/MastodonSDK/Query/Query.swift index 7fbe0da9e..7e27eb50a 100644 --- a/MastodonSDK/Sources/MastodonSDK/Query/Query.swift +++ b/MastodonSDK/Sources/MastodonSDK/Query/Query.swift @@ -62,6 +62,6 @@ protocol PutQuery: RequestQuery { } protocol DeleteQuery: RequestQuery { } extension DeleteQuery { - // By default a `PostQuery` does not has query items + // By default a `DeleteQuery` does not has query items var queryItems: [URLQueryItem]? { nil } }