Show confirmation dialog when deleting post (#713) close #712

* Show confirmation dialog when deleting post

* Localization

* Fixes

---------

Co-authored-by: Yusuke Arakawa <nekolaboratory@users.noreply.github.com>
Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
Yusuke Arakawa 2023-02-08 14:24:09 +09:00 committed by GitHub
parent 17ea15c819
commit e953c243cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 47 additions and 3 deletions

View file

@ -325,6 +325,8 @@
"status.action.boost" = "Impulsa";
"status.action.copy-text" = "Copia el text";
"status.action.delete" = "Elimina";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Edita";
"status.action.favorite" = "Marca com a preferit";
"status.action.mention" = "Menciona";

View file

@ -326,6 +326,8 @@
"status.action.boost" = "Boosten";
"status.action.copy-text" = "Text kopieren";
"status.action.delete" = "Löschen";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Bearbeiten";
"status.action.favorite" = "Favorisieren";
"status.action.mention" = "Erwähnen";

View file

@ -328,6 +328,8 @@
"status.action.boost" = "Boost";
"status.action.copy-text" = "Copy Text";
"status.action.delete" = "Delete";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Edit";
"status.action.favorite" = "Favourite";
"status.action.mention" = "Mention";

View file

@ -327,6 +327,8 @@
"status.action.boost" = "Boost";
"status.action.copy-text" = "Copy Text";
"status.action.delete" = "Delete";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Edit";
"status.action.favorite" = "Favorite";
"status.action.mention" = "Mention";

View file

@ -327,6 +327,8 @@
"status.action.boost" = "Retootear";
"status.action.copy-text" = "Copiar texto";
"status.action.delete" = "Borrar";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Editar";
"status.action.favorite" = "Marcar como favorito";
"status.action.mention" = "Mencionar";

View file

@ -322,6 +322,8 @@
"status.action.boost" = "Promouvoir";
"status.action.copy-text" = "Copier le texte";
"status.action.delete" = "Supprimer";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Modifier";
"status.action.favorite" = "Favori";
"status.action.mention" = "Mentionner";

View file

@ -327,6 +327,8 @@
"status.action.boost" = "Condividi";
"status.action.copy-text" = "Copia il testo";
"status.action.delete" = "Elimina";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Modifica";
"status.action.favorite" = "Apprezza";
"status.action.mention" = "Menziona";

View file

@ -326,6 +326,8 @@
"status.action.boost" = "ブースト";
"status.action.copy-text" = "テキストをコピー";
"status.action.delete" = "削除";
"status.action.delete.confirm.title" = "確認";
"status.action.delete.confirm.message" = "本当に投稿を削除しますか?";
"status.action.edit" = "編集";
"status.action.favorite" = "お気に入り";
"status.action.mention" = "返信";

View file

@ -328,6 +328,8 @@
"status.action.boost" = "부스트";
"status.action.copy-text" = "복사";
"status.action.delete" = "삭제";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "수정";
"status.action.favorite" = "좋아요";
"status.action.mention" = "언급";

View file

@ -326,6 +326,8 @@
"status.action.boost" = "Forsterk";
"status.action.copy-text" = "Kopier tekst";
"status.action.delete" = "Slett";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Rediger";
"status.action.favorite" = "Favoritt";
"status.action.mention" = "Omtal";

View file

@ -320,6 +320,8 @@
"status.action.boost" = "Boosten";
"status.action.copy-text" = "Kopieer tekst";
"status.action.delete" = "Verwijder";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Bewerk";
"status.action.favorite" = "Maak favoriet";
"status.action.mention" = "Vermelden";

View file

@ -322,6 +322,8 @@
"status.action.boost" = "Podbij";
"status.action.copy-text" = "Kopiuj tekst";
"status.action.delete" = "Usuń";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Edytuj";
"status.action.favorite" = "Dodaj do polubionych";
"status.action.mention" = "Wymień osobę";

View file

@ -326,6 +326,8 @@
"status.action.boost" = "Boost";
"status.action.copy-text" = "Copiar Texto";
"status.action.delete" = "Deletar";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Editar";
"status.action.favorite" = "Favoritar";
"status.action.mention" = "Menção";

View file

@ -322,6 +322,8 @@
"status.action.boost" = "Yükselt";
"status.action.copy-text" = "Yazıyı Kopyala";
"status.action.delete" = "Sil";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "Düzenle";
"status.action.favorite" = "Favori";
"status.action.mention" = "Bahset";

View file

@ -327,6 +327,8 @@
"status.action.boost" = "转发";
"status.action.copy-text" = "拷贝文本";
"status.action.delete" = "删除";
"status.action.delete.confirm.title" = "Confirm";
"status.action.delete.confirm.message" = "are you sure you want to delete this post?";
"status.action.edit" = "编辑";
"status.action.favorite" = "收藏";
"status.action.mention" = "提及";

View file

@ -112,9 +112,10 @@ struct StatusRowContextMenu: View {
Label("status.action.edit", systemImage: "pencil")
}
}
Button(role: .destructive) { Task { await viewModel.delete() } } label: {
Label("status.action.delete", systemImage: "trash")
}
Button(role: .destructive,
action: { viewModel.showDeleteAlert = true },
label: { Label("status.action.delete", systemImage: "trash") }
)
}
} else if !viewModel.isRemote {
Section(viewModel.status.account.acct) {

View file

@ -127,6 +127,18 @@ public struct StatusRowView: View {
remoteContentLoadingView
}
}
.alert(isPresented: $viewModel.showDeleteAlert, content: {
Alert(
title: Text("status.action.delete.confirm.title"),
message: Text("status.action.delete.confirm.message"),
primaryButton: .destructive(
Text("status.action.delete")) {
Task {
await viewModel.delete()
}
},
secondaryButton: .cancel())
})
.alignmentGuide(.listRowSeparatorLeading) { _ in
-100
}

View file

@ -26,6 +26,7 @@ public class StatusRowViewModel: ObservableObject {
@Published var translation: String?
@Published var isLoadingTranslation: Bool = false
@Published var showDeleteAlert: Bool = false
@Published var favoriters: [Account] = []
@Published var rebloggers: [Account] = []