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] {
|
func actionsForStatus(_ status: StatusMO, source: PopoverSource, includeStatusButtonActions: Bool = true) -> [UIMenuElement] {
|
||||||
guard let mastodonController = mastodonController else { return [] }
|
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
|
// user is logged out
|
||||||
return [
|
return [
|
||||||
openInSafariAction(url: status.url!),
|
openInSafariAction(url: status.url!),
|
||||||
|
@ -230,15 +231,7 @@ extension MenuActionProvider {
|
||||||
}), at: 1)
|
}), at: 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
var actionsSection: [UIAction] = [
|
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)
|
|
||||||
})
|
|
||||||
]
|
|
||||||
|
|
||||||
if includeStatusButtonActions {
|
if includeStatusButtonActions {
|
||||||
actionsSection.insert(createAction(identifier: "reply", title: "Reply", systemImageName: "arrowshape.turn.up.left", handler: { [weak self] (_) in
|
actionsSection.insert(createAction(identifier: "reply", title: "Reply", systemImageName: "arrowshape.turn.up.left", handler: { [weak self] (_) in
|
||||||
|
@ -247,42 +240,40 @@ extension MenuActionProvider {
|
||||||
}), at: 0)
|
}), 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)
|
||||||
// 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 }) {
|
||||||
if status.account.id == account.id || status.mentions.contains(where: { $0.id == account.id }) {
|
let muted = status.muted
|
||||||
let muted = status.muted
|
toggleableSection.append(createAction(identifier: "mute", title: muted ? "Unmute Conversation" : "Mute Conversation", systemImageName: muted ? "speaker" : "speaker.slash", handler: { [weak self] (_) in
|
||||||
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 }
|
||||||
guard let self = self else { return }
|
let request = (muted ? Status.unmuteConversation : Status.muteConversation)(status.id)
|
||||||
let request = (muted ? Status.unmuteConversation : Status.muteConversation)(status.id)
|
self.mastodonController?.run(request) { (response) in
|
||||||
self.mastodonController?.run(request) { (response) in
|
switch response {
|
||||||
switch response {
|
case .success(let status, _):
|
||||||
case .success(let status, _):
|
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
||||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
case .failure(let error):
|
||||||
case .failure(let error):
|
self.handleError(error, title: "Error \(muted ? "Unm" : "M")uting")
|
||||||
self.handleError(error, title: "Error \(muted ? "Unm" : "M")uting")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}))
|
}
|
||||||
}
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
// only allowing pinning user's own statuses
|
// only allowing pinning user's own statuses
|
||||||
if account.id == status.account.id,
|
if account.id == status.account.id,
|
||||||
mastodonController.instanceFeatures.profilePinnedStatuses {
|
mastodonController.instanceFeatures.profilePinnedStatuses {
|
||||||
let pinned = status.pinned ?? false
|
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
|
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 }
|
guard let self = self else { return }
|
||||||
let request = (pinned ? Status.unpin : Status.pin)(status.id)
|
switch response {
|
||||||
self.mastodonController?.run(request, completion: { [weak self] (response) in
|
case .success(let status, _):
|
||||||
guard let self = self else { return }
|
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
||||||
switch response {
|
case .failure(let error):
|
||||||
case .success(let status, _):
|
self.handleError(error, title: "Error \(pinned ? "Unp" :"P")inning")
|
||||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status)
|
}
|
||||||
case .failure(let error):
|
})
|
||||||
self.handleError(error, title: "Error \(pinned ? "Unp" :"P")inning")
|
}))
|
||||||
}
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.poll != nil {
|
if status.poll != nil {
|
||||||
|
@ -304,6 +295,17 @@ extension MenuActionProvider {
|
||||||
}), at: 0)
|
}), 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] = []
|
var shareSection: [UIAction] = []
|
||||||
if let url = status.url {
|
if let url = status.url {
|
||||||
shareSection.append(openInSafariAction(url: url))
|
shareSection.append(openInSafariAction(url: url))
|
||||||
|
|
Loading…
Reference in New Issue