forked from shadowfacts/Tusker
Don't show Mute action when not applicable to status
This commit is contained in:
parent
ca5ac8b826
commit
5a914ea5a3
|
@ -12,6 +12,7 @@ public class Mention: Codable {
|
||||||
public let url: URL
|
public let url: URL
|
||||||
public let username: String
|
public let username: String
|
||||||
public let acct: String
|
public let acct: String
|
||||||
|
/// The instance-local ID of the user being mentioned.
|
||||||
public let id: String
|
public let id: String
|
||||||
|
|
||||||
private enum CodingKeys: String, CodingKey {
|
private enum CodingKeys: String, CodingKey {
|
||||||
|
|
|
@ -156,7 +156,6 @@ extension MenuPreviewProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
let bookmarked = status.bookmarked ?? false
|
let bookmarked = status.bookmarked ?? false
|
||||||
let muted = status.muted
|
|
||||||
|
|
||||||
var actionsSection = [
|
var actionsSection = [
|
||||||
createAction(identifier: "bookmark", title: bookmarked ? "Unbookmark" : "Bookmark", systemImageName: bookmarked ? "bookmark.fill" : "bookmark", handler: { [weak self] (_) in
|
createAction(identifier: "bookmark", title: bookmarked ? "Unbookmark" : "Bookmark", systemImageName: bookmarked ? "bookmark.fill" : "bookmark", handler: { [weak self] (_) in
|
||||||
|
@ -168,15 +167,6 @@ extension MenuPreviewProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
createAction(identifier: "mute", title: muted ? "Unmute" : "Mute", 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
|
|
||||||
if case let .success(status, _) = response {
|
|
||||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status, incrementReferenceCount: false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if includeReply {
|
if includeReply {
|
||||||
|
@ -186,18 +176,35 @@ extension MenuPreviewProvider {
|
||||||
}), at: 0)
|
}), at: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if mastodonController.account != nil && mastodonController.account.id == status.account.id {
|
if let account = mastodonController.account {
|
||||||
let pinned = status.pinned ?? false
|
// only allow muting conversations that either current user posted or is participating in (technically, is mentioned, since that's the best we can do)
|
||||||
actionsSection.append(createAction(identifier: "pin", title: pinned ? "Unpin from Profile" : "Pin to Profile", systemImageName: pinned ? "pin.slash" : "pin", handler: { [weak self] (_) in
|
if status.account.id == account.id || status.mentions.contains(where: { $0.id == account.id }) {
|
||||||
guard let self = self else { return }
|
let muted = status.muted
|
||||||
let request = (pinned ? Status.unpin : Status.pin)(status.id)
|
actionsSection.append(createAction(identifier: "mute", title: muted ? "Unmute Conversation" : "Mute Conversation", systemImageName: muted ? "speaker" : "speaker.slash", handler: { [weak self] (_) in
|
||||||
self.mastodonController?.run(request, completion: { [weak self] (response) in
|
|
||||||
guard let self = self else { return }
|
guard let self = self else { return }
|
||||||
if case let .success(status, _) = response {
|
let request = (muted ? Status.unmuteConversation : Status.muteConversation)(status.id)
|
||||||
self.mastodonController?.persistentContainer.addOrUpdate(status: status, incrementReferenceCount: false)
|
self.mastodonController?.run(request) { (response) in
|
||||||
|
if case let .success(status, _) = response {
|
||||||
|
self.mastodonController?.persistentContainer.addOrUpdate(status: status, incrementReferenceCount: false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
}))
|
||||||
}))
|
}
|
||||||
|
|
||||||
|
// only allowing pinning user's own statuses
|
||||||
|
if account.id == status.account.id {
|
||||||
|
let pinned = status.pinned ?? false
|
||||||
|
actionsSection.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 }
|
||||||
|
if case let .success(status, _) = response {
|
||||||
|
self.mastodonController?.persistentContainer.addOrUpdate(status: status, incrementReferenceCount: false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if status.poll != nil {
|
if status.poll != nil {
|
||||||
|
|
Loading…
Reference in New Issue