Only show report action for other people's posts
This commit is contained in:
parent
6f006adbc1
commit
5f19adf2d0
|
@ -172,7 +172,8 @@ extension MenuActionProvider {
|
|||
func actionsForStatus(_ status: StatusMO, source: PopoverSource, includeStatusButtonActions: Bool = true) -> [UIMenuElement] {
|
||||
guard let mastodonController = mastodonController else { return [] }
|
||||
|
||||
guard let accountID = mastodonController.accountInfo?.id else {
|
||||
guard let accountID = mastodonController.accountInfo?.id,
|
||||
let account = mastodonController.account else {
|
||||
// user is logged out
|
||||
return [
|
||||
openInSafariAction(url: status.url!),
|
||||
|
@ -230,15 +231,7 @@ extension MenuActionProvider {
|
|||
}), at: 1)
|
||||
}
|
||||
|
||||
var actionsSection: [UIAction] = [
|
||||
createAction(identifier: "report", title: "Report", systemImageName: "flag", handler: { [weak self] _ in
|
||||
let report = EditedReport(accountID: status.account.id)
|
||||
report.statusIDs = [status.id]
|
||||
let view = ReportView(report: report, mastodonController: mastodonController)
|
||||
let host = UIHostingController(rootView: view)
|
||||
self?.navigationDelegate?.present(host, animated: true)
|
||||
})
|
||||
]
|
||||
var actionsSection: [UIAction] = []
|
||||
|
||||
if includeStatusButtonActions {
|
||||
actionsSection.insert(createAction(identifier: "reply", title: "Reply", systemImageName: "arrowshape.turn.up.left", handler: { [weak self] (_) in
|
||||
|
@ -247,42 +240,40 @@ extension MenuActionProvider {
|
|||
}), at: 0)
|
||||
}
|
||||
|
||||
if let account = mastodonController.account {
|
||||
// only allow muting conversations that either current user posted or is participating in (technically, is mentioned, since that's the best we can do)
|
||||
if status.account.id == account.id || status.mentions.contains(where: { $0.id == account.id }) {
|
||||
let muted = status.muted
|
||||
toggleableSection.append(createAction(identifier: "mute", title: muted ? "Unmute Conversation" : "Mute Conversation", systemImageName: muted ? "speaker" : "speaker.slash", handler: { [weak self] (_) in
|
||||
guard let self = self else { return }
|
||||
let request = (muted ? Status.unmuteConversation : Status.muteConversation)(status.id)
|
||||
self.mastodonController?.run(request) { (response) in
|
||||
switch response {
|
||||
case .success(let status, _):
|
||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
||||
case .failure(let error):
|
||||
self.handleError(error, title: "Error \(muted ? "Unm" : "M")uting")
|
||||
}
|
||||
// only allow muting conversations that either current user posted or is participating in (technically, is mentioned, since that's the best we can do)
|
||||
if status.account.id == account.id || status.mentions.contains(where: { $0.id == account.id }) {
|
||||
let muted = status.muted
|
||||
toggleableSection.append(createAction(identifier: "mute", title: muted ? "Unmute Conversation" : "Mute Conversation", systemImageName: muted ? "speaker" : "speaker.slash", handler: { [weak self] (_) in
|
||||
guard let self = self else { return }
|
||||
let request = (muted ? Status.unmuteConversation : Status.muteConversation)(status.id)
|
||||
self.mastodonController?.run(request) { (response) in
|
||||
switch response {
|
||||
case .success(let status, _):
|
||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
||||
case .failure(let error):
|
||||
self.handleError(error, title: "Error \(muted ? "Unm" : "M")uting")
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
// only allowing pinning user's own statuses
|
||||
if account.id == status.account.id,
|
||||
mastodonController.instanceFeatures.profilePinnedStatuses {
|
||||
let pinned = status.pinned ?? false
|
||||
toggleableSection.append(createAction(identifier: "pin", title: pinned ? "Unpin from Profile" : "Pin to Profile", systemImageName: pinned ? "pin.slash" : "pin", handler: { [weak self] (_) in
|
||||
// only allowing pinning user's own statuses
|
||||
if account.id == status.account.id,
|
||||
mastodonController.instanceFeatures.profilePinnedStatuses {
|
||||
let pinned = status.pinned ?? false
|
||||
toggleableSection.append(createAction(identifier: "pin", title: pinned ? "Unpin from Profile" : "Pin to Profile", systemImageName: pinned ? "pin.slash" : "pin", handler: { [weak self] (_) in
|
||||
guard let self = self else { return }
|
||||
let request = (pinned ? Status.unpin : Status.pin)(status.id)
|
||||
self.mastodonController?.run(request, completion: { [weak self] (response) in
|
||||
guard let self = self else { return }
|
||||
let request = (pinned ? Status.unpin : Status.pin)(status.id)
|
||||
self.mastodonController?.run(request, completion: { [weak self] (response) in
|
||||
guard let self = self else { return }
|
||||
switch response {
|
||||
case .success(let status, _):
|
||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
||||
case .failure(let error):
|
||||
self.handleError(error, title: "Error \(pinned ? "Unp" :"P")inning")
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
switch response {
|
||||
case .success(let status, _):
|
||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
||||
case .failure(let error):
|
||||
self.handleError(error, title: "Error \(pinned ? "Unp" :"P")inning")
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
if status.poll != nil {
|
||||
|
@ -304,6 +295,17 @@ extension MenuActionProvider {
|
|||
}), at: 0)
|
||||
}
|
||||
|
||||
// can only report other people's posts
|
||||
if account.id != status.account.id {
|
||||
actionsSection.append(createAction(identifier: "report", title: "Report", systemImageName: "flag", handler: { [weak self] _ in
|
||||
let report = EditedReport(accountID: status.account.id)
|
||||
report.statusIDs = [status.id]
|
||||
let view = ReportView(report: report, mastodonController: mastodonController)
|
||||
let host = UIHostingController(rootView: view)
|
||||
self?.navigationDelegate?.present(host, animated: true)
|
||||
}))
|
||||
}
|
||||
|
||||
var shareSection: [UIAction] = []
|
||||
if let url = status.url {
|
||||
shareSection.append(openInSafariAction(url: url))
|
||||
|
|
Loading…
Reference in New Issue