Move notification and reboosts actions into account menu (#382)

This commit is contained in:
Jérôme Danthinne 2023-01-25 21:15:32 +01:00 committed by GitHub
parent d10e71a7c3
commit d0f16c84f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 99 additions and 10 deletions

View File

@ -141,6 +141,10 @@
"account.action.edit-info" = "Info bearbeiten";
"account.action.mention" = "Erwähnen";
"account.action.message" = "Nachricht";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "Blockieren";
"account.action.unblock" = "Block aufheben";
"account.action.mute" = "Stummschalten";

View File

@ -144,6 +144,10 @@
"account.action.edit-info" = "Edit Info";
"account.action.mention" = "Mention";
"account.action.message" = "Message";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "Block";
"account.action.unblock" = "Unblock";
"account.action.mute" = "Mute";

View File

@ -144,6 +144,10 @@
"account.action.edit-info" = "Editar información";
"account.action.mention" = "Mencionar";
"account.action.message" = "Enviar mensaje";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "Bloquear";
"account.action.unblock" = "Desbloquear";
"account.action.mute" = "Silenciar";

View File

@ -141,6 +141,10 @@
"account.action.edit-info" = "Modifica informazioni";
"account.action.mention" = "Menziona";
"account.action.message" = "Messaggio";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "Blocca";
"account.action.unblock" = "Sblocca";
"account.action.mute" = "Silenzia";

View File

@ -127,6 +127,10 @@
"account.action.edit-info" = "プロフィールを編集";
"account.action.mention" = "返信";
"account.action.message" = "メッセージ";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "ブロック";
"account.action.unblock" = "ブロック解除";
"account.action.mute" = "ミュート";

View File

@ -141,6 +141,10 @@
"account.action.edit-info" = "Bewerken";
"account.action.mention" = "Vermelden";
"account.action.message" = "Bericht sturen";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "Blokkeren";
"account.action.unblock" = "Deblokkeren";
"account.action.mute" = "Dempen";

View File

@ -131,6 +131,10 @@
"account.action.edit-info" = "Bilgiyi Düzenle";
"account.action.mention" = "Bahset";
"account.action.message" = "Mesaj Gönder";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "Engelle";
"account.action.unblock" = "Engeli Kaldır";
"account.action.mute" = "Sustur";

View File

@ -142,6 +142,10 @@
"account.action.edit-info" = "编辑个人资料";
"account.action.mention" = "提及";
"account.action.message" = "私信";
"account.action.notify-enable" = "Enable Notifications";
"account.action.notify-disable" = "Disable Notifications";
"account.action.reboosts-show" = "Show Boosts";
"account.action.reboosts-hide" = "Hide Boosts";
"account.action.block" = "拉黑";
"account.action.unblock" = "取消拉黑";
"account.action.mute" = "免打扰";

View File

@ -421,6 +421,66 @@ public struct AccountDetailView: View {
Label("account.action.mute", systemImage: "speaker.slash")
}
}
if let relationship = viewModel.relationship,
relationship.following
{
if relationship.notifying {
Button {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.unmute(id: account.id))
} catch {
print("Error while disabling notifications: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.notify-disable", systemImage: "bell.fill")
}
} else {
Button {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.mute(id: account.id))
} catch {
print("Error while enabling notifications: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.notify-enable", systemImage: "bell")
}
}
if relationship.showingReblogs {
Button {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.follow(id: account.id,
notify: relationship.notifying,
reblogs: false))
} catch {
print("Error while disabling reboosts: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.reboosts-hide", systemImage: "arrow.left.arrow.right.circle.fill")
}
} else {
Button {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.follow(id: account.id,
notify: relationship.notifying,
reblogs: true))
} catch {
print("Error while enabling reboosts: \(error.localizedDescription)")
}
}
} label: {
Label("account.action.reboosts-show", systemImage: "arrow.left.arrow.right.circle")
}
}
}
Divider()
}
@ -451,7 +511,7 @@ public struct AccountDetailView: View {
}
}
} label: {
Image(systemName: "ellipsis")
Image(systemName: "ellipsis.circle.fill")
}
}
}

View File

@ -82,7 +82,7 @@ public struct FollowButton: View {
}
public var body: some View {
VStack {
VStack(alignment: .trailing) {
Button {
Task {
if viewModel.relationship.following {
@ -98,9 +98,9 @@ public struct FollowButton: View {
Text(viewModel.relationship.following ? "account.follow.following" : "account.follow.follow")
}
}
.buttonStyle(.bordered)
.disabled(viewModel.isUpdating)
if viewModel.relationship.following, viewModel.shouldDisplayNotify {
if viewModel.relationship.following,
viewModel.shouldDisplayNotify
{
HStack {
Button {
Task {
@ -109,9 +109,6 @@ public struct FollowButton: View {
} label: {
Image(systemName: viewModel.relationship.notifying ? "bell.fill" : "bell")
}
.buttonStyle(.bordered)
.disabled(viewModel.isUpdating)
Button {
Task {
await viewModel.toggleReboosts()
@ -119,11 +116,11 @@ public struct FollowButton: View {
} label: {
Image(systemName: viewModel.relationship.showingReblogs ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle")
}
.buttonStyle(.bordered)
.disabled(viewModel.isUpdating)
}
}
}
.buttonStyle(.bordered)
.disabled(viewModel.isUpdating)
.onAppear {
viewModel.client = client
}