New status row context menu

This commit is contained in:
Thomas Ricouard 2024-01-22 09:14:45 +01:00
parent 9a8568d3fa
commit 46b8fbde29

View file

@ -37,6 +37,16 @@ struct StatusRowContextMenu: View {
var body: some View {
if !viewModel.isRemote {
ControlGroup {
Button {
#if targetEnvironment(macCatalyst) || os(visionOS)
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
#else
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
#endif
} label: {
Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
}
Button { Task {
HapticManager.shared.fireHaptic(.notification(.success))
SoundEffectManager.shared.playSound(.favorite)
@ -60,15 +70,8 @@ struct StatusRowContextMenu: View {
Label(statusDataController.isBookmarked ? "status.action.unbookmark" : "status.action.bookmark",
systemImage: statusDataController.isBookmarked ? "bookmark.fill" : "bookmark")
}
Button {
#if targetEnvironment(macCatalyst) || os(visionOS)
openWindow(value: WindowDestinationEditor.replyToStatusEditor(status: viewModel.status))
#else
viewModel.routerPath.presentedSheet = .replyToStatusEditor(status: viewModel.status)
#endif
} label: {
Label("status.action.reply", systemImage: "arrowshape.turn.up.left")
}
.controlGroupStyle(.compactMenu)
Button {
#if targetEnvironment(macCatalyst) || os(visionOS)
openWindow(value: WindowDestinationEditor.quoteStatusEditor(status: viewModel.status))
@ -194,45 +197,6 @@ struct StatusRowContextMenu: View {
} else {
if !viewModel.isRemote {
Section(viewModel.status.reblog?.account.acct ?? viewModel.status.account.acct) {
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .pub)
} label: {
Label("status.action.mention", systemImage: "at")
}
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .direct)
} label: {
Label("status.action.message", systemImage: "tray.full")
}
if viewModel.authorRelationship?.blocking == true {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.unblock(id: operationAccount.id))
} catch {
print("Error while unblocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.unblock", systemImage: "person.crop.circle.badge.exclamationmark")
}
} else {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.block(id: operationAccount.id))
} catch {
print("Error while blocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
}
}
if viewModel.authorRelationship?.muting == true {
Button {
Task {
@ -264,6 +228,45 @@ struct StatusRowContextMenu: View {
Label("account.action.mute", systemImage: "speaker.slash")
}
}
ControlGroup {
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .pub)
} label: {
Label("status.action.mention", systemImage: "at")
}
Button {
viewModel.routerPath.presentedSheet = .mentionStatusEditor(account: viewModel.status.reblog?.account ?? viewModel.status.account, visibility: .direct)
} label: {
Label("status.action.message", systemImage: "tray.full")
}
if viewModel.authorRelationship?.blocking == true {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.unblock(id: operationAccount.id))
} catch {
print("Error while unblocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.unblock", systemImage: "person.crop.circle.badge.exclamationmark")
}
} else {
Button {
Task {
do {
let operationAccount = viewModel.status.reblog?.account ?? viewModel.status.account
viewModel.authorRelationship = try await client.post(endpoint: Accounts.block(id: operationAccount.id))
} catch {
print("Error while blocking: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
}
}
}
}
}
Section {