Fix status actions on boosting posts (#974)

* Fix context menus for boosts

* Allow my boost of my followers-only post

* Disable boost context menu on posts can't be boosted and show different string for boosting my own private post

* Localizations

* CR

---------

Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
Chanhwi Joo 2023-02-21 14:59:47 +09:00 committed by GitHub
parent 64b54cb31b
commit f04c15b8fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 47 additions and 6 deletions

View file

@ -359,6 +359,7 @@
"status.action.translated-label-%@" = "Пераклад з дапамогай %@"; "status.action.translated-label-%@" = "Пераклад з дапамогай %@";
"status.action.bookmark" = "Закладка"; "status.action.bookmark" = "Закладка";
"status.action.boost" = "Павышэнне"; "status.action.boost" = "Павышэнне";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Капіяваць тэкст"; "status.action.copy-text" = "Капіяваць тэкст";
"status.action.delete" = "Выдаліць"; "status.action.delete" = "Выдаліць";
"status.action.delete.confirm.title" = "Пацвердзіць"; "status.action.delete.confirm.title" = "Пацвердзіць";

View file

@ -369,6 +369,7 @@
"status.action.translated-label-%@" = "Traduït amb %@"; "status.action.translated-label-%@" = "Traduït amb %@";
"status.action.bookmark" = "Afegeix als marcadors"; "status.action.bookmark" = "Afegeix als marcadors";
"status.action.boost" = "Impulsa"; "status.action.boost" = "Impulsa";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copia el text"; "status.action.copy-text" = "Copia el text";
"status.action.delete" = "Elimina"; "status.action.delete" = "Elimina";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -366,6 +366,7 @@
"status.action.translated-label-%@" = "Übersetzt mit %@"; "status.action.translated-label-%@" = "Übersetzt mit %@";
"status.action.bookmark" = "Lesezeichen setzen"; "status.action.bookmark" = "Lesezeichen setzen";
"status.action.boost" = "Boosten"; "status.action.boost" = "Boosten";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Text kopieren"; "status.action.copy-text" = "Text kopieren";
"status.action.delete" = "Löschen"; "status.action.delete" = "Löschen";
"status.action.delete.confirm.title" = "Bestätigen"; "status.action.delete.confirm.title" = "Bestätigen";

View file

@ -372,6 +372,7 @@
"status.action.translated-label-%@" = "Translated using %@"; "status.action.translated-label-%@" = "Translated using %@";
"status.action.bookmark" = "Bookmark"; "status.action.bookmark" = "Bookmark";
"status.action.boost" = "Boost"; "status.action.boost" = "Boost";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copy Text"; "status.action.copy-text" = "Copy Text";
"status.action.delete" = "Delete"; "status.action.delete" = "Delete";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -371,6 +371,7 @@
"status.action.translated-label-%@" = "Translated using %@"; "status.action.translated-label-%@" = "Translated using %@";
"status.action.bookmark" = "Bookmark"; "status.action.bookmark" = "Bookmark";
"status.action.boost" = "Boost"; "status.action.boost" = "Boost";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copy Text"; "status.action.copy-text" = "Copy Text";
"status.action.delete" = "Delete"; "status.action.delete" = "Delete";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -371,6 +371,7 @@
"status.action.translated-label-%@" = "Traducido usando %@"; "status.action.translated-label-%@" = "Traducido usando %@";
"status.action.bookmark" = "Añadir a marcadores"; "status.action.bookmark" = "Añadir a marcadores";
"status.action.boost" = "Retootear"; "status.action.boost" = "Retootear";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copiar texto"; "status.action.copy-text" = "Copiar texto";
"status.action.delete" = "Borrar"; "status.action.delete" = "Borrar";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -364,6 +364,7 @@
"status.action.translated-label-%@" = "%@ erabiliz itzulia"; "status.action.translated-label-%@" = "%@ erabiliz itzulia";
"status.action.bookmark" = "Jarri laster-marka"; "status.action.bookmark" = "Jarri laster-marka";
"status.action.boost" = "Bultzatu"; "status.action.boost" = "Bultzatu";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Kopiatu testua"; "status.action.copy-text" = "Kopiatu testua";
"status.action.delete" = "Ezabatu"; "status.action.delete" = "Ezabatu";
"status.action.delete.confirm.title" = "Baieztatu"; "status.action.delete.confirm.title" = "Baieztatu";

View file

@ -366,6 +366,7 @@
"status.action.translated-label-%@" = "Traduit avec %@"; "status.action.translated-label-%@" = "Traduit avec %@";
"status.action.bookmark" = "Marquer"; "status.action.bookmark" = "Marquer";
"status.action.boost" = "Promouvoir"; "status.action.boost" = "Promouvoir";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copier le texte"; "status.action.copy-text" = "Copier le texte";
"status.action.delete" = "Supprimer"; "status.action.delete" = "Supprimer";
"status.action.delete.confirm.title" = "Confirmer"; "status.action.delete.confirm.title" = "Confirmer";

View file

@ -371,6 +371,7 @@
"status.action.translated-label-%@" = "Tradotto usando %@"; "status.action.translated-label-%@" = "Tradotto usando %@";
"status.action.bookmark" = "Salva nei segnalibri"; "status.action.bookmark" = "Salva nei segnalibri";
"status.action.boost" = "Condividi"; "status.action.boost" = "Condividi";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copia il testo"; "status.action.copy-text" = "Copia il testo";
"status.action.delete" = "Elimina"; "status.action.delete" = "Elimina";
"status.action.delete.confirm.title" = "Richiesta di conferma"; "status.action.delete.confirm.title" = "Richiesta di conferma";

View file

@ -370,6 +370,7 @@
"status.action.translated-label-%@" = "%@ を使用して翻訳"; "status.action.translated-label-%@" = "%@ を使用して翻訳";
"status.action.bookmark" = "ブックマーク"; "status.action.bookmark" = "ブックマーク";
"status.action.boost" = "ブースト"; "status.action.boost" = "ブースト";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "テキストをコピー"; "status.action.copy-text" = "テキストをコピー";
"status.action.delete" = "削除"; "status.action.delete" = "削除";
"status.action.delete.confirm.title" = "確認"; "status.action.delete.confirm.title" = "確認";

View file

@ -372,6 +372,7 @@
"status.action.translated-label-%@" = "번역 제공: %@"; "status.action.translated-label-%@" = "번역 제공: %@";
"status.action.bookmark" = "보관함에 추가"; "status.action.bookmark" = "보관함에 추가";
"status.action.boost" = "부스트"; "status.action.boost" = "부스트";
"status.action.boost-to-followers" = "팔로워에게 부스트";
"status.action.copy-text" = "복사"; "status.action.copy-text" = "복사";
"status.action.delete" = "삭제"; "status.action.delete" = "삭제";
"status.action.delete.confirm.title" = "삭제 확인"; "status.action.delete.confirm.title" = "삭제 확인";

View file

@ -370,6 +370,7 @@
"status.action.translated-label-%@" = "Oversatt ved hjelp av %@"; "status.action.translated-label-%@" = "Oversatt ved hjelp av %@";
"status.action.bookmark" = "Bokmerk"; "status.action.bookmark" = "Bokmerk";
"status.action.boost" = "Forsterk"; "status.action.boost" = "Forsterk";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Kopier tekst"; "status.action.copy-text" = "Kopier tekst";
"status.action.delete" = "Slett"; "status.action.delete" = "Slett";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -364,6 +364,7 @@
"status.action.translated-label-%@" = "Vertaald met behulp van %@"; "status.action.translated-label-%@" = "Vertaald met behulp van %@";
"status.action.bookmark" = "Voeg bladwijzer toe"; "status.action.bookmark" = "Voeg bladwijzer toe";
"status.action.boost" = "Boosten"; "status.action.boost" = "Boosten";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Kopieer tekst"; "status.action.copy-text" = "Kopieer tekst";
"status.action.delete" = "Verwijder"; "status.action.delete" = "Verwijder";
"status.action.delete.confirm.title" = "Bevestigen"; "status.action.delete.confirm.title" = "Bevestigen";

View file

@ -366,6 +366,7 @@
"status.action.translated-label-%@" = "Przetłumaczono za pomocą %@"; "status.action.translated-label-%@" = "Przetłumaczono za pomocą %@";
"status.action.bookmark" = "Dodaj zakładkę"; "status.action.bookmark" = "Dodaj zakładkę";
"status.action.boost" = "Podbij"; "status.action.boost" = "Podbij";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Kopiuj tekst"; "status.action.copy-text" = "Kopiuj tekst";
"status.action.delete" = "Usuń"; "status.action.delete" = "Usuń";
"status.action.delete.confirm.title" = "Potwierdź"; "status.action.delete.confirm.title" = "Potwierdź";

View file

@ -370,6 +370,7 @@
"status.action.translated-label-%@" = "Traduzir usando %@"; "status.action.translated-label-%@" = "Traduzir usando %@";
"status.action.bookmark" = "Salvar"; "status.action.bookmark" = "Salvar";
"status.action.boost" = "Boost"; "status.action.boost" = "Boost";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Copiar Texto"; "status.action.copy-text" = "Copiar Texto";
"status.action.delete" = "Deletar"; "status.action.delete" = "Deletar";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -366,6 +366,7 @@
"status.action.translated-label-%@" = "%@ tarafından tercüme edildi"; "status.action.translated-label-%@" = "%@ tarafından tercüme edildi";
"status.action.bookmark" = "Yer İmi Ekle"; "status.action.bookmark" = "Yer İmi Ekle";
"status.action.boost" = "Yükselt"; "status.action.boost" = "Yükselt";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "Yazıyı Kopyala"; "status.action.copy-text" = "Yazıyı Kopyala";
"status.action.delete" = "Sil"; "status.action.delete" = "Sil";
"status.action.delete.confirm.title" = "Confirm"; "status.action.delete.confirm.title" = "Confirm";

View file

@ -369,6 +369,7 @@
"status.action.translated-label-%@" = "由 %@ 翻译"; "status.action.translated-label-%@" = "由 %@ 翻译";
"status.action.bookmark" = "书签"; "status.action.bookmark" = "书签";
"status.action.boost" = "转发"; "status.action.boost" = "转发";
"status.action.boost-to-followers" = "Boost to Followers";
"status.action.copy-text" = "拷贝文本"; "status.action.copy-text" = "拷贝文本";
"status.action.delete" = "删除"; "status.action.delete" = "删除";
"status.action.delete.confirm.title" = "确认删除"; "status.action.delete.confirm.title" = "确认删除";

View file

@ -6,17 +6,26 @@ import SwiftUI
struct StatusRowActionsView: View { struct StatusRowActionsView: View {
@EnvironmentObject private var theme: Theme @EnvironmentObject private var theme: Theme
@EnvironmentObject private var currentAccount: CurrentAccount
@ObservedObject var viewModel: StatusRowViewModel @ObservedObject var viewModel: StatusRowViewModel
func privateBoost() -> Bool {
return self.viewModel.status.visibility == .priv && self.viewModel.status.account.id == self.currentAccount.account?.id
}
@MainActor @MainActor
enum Actions: CaseIterable { enum Actions: CaseIterable {
case respond, boost, favorite, bookmark, share case respond, boost, favorite, bookmark, share
func iconName(viewModel: StatusRowViewModel) -> String { func iconName(viewModel: StatusRowViewModel, privateBoost: Bool = false) -> String {
switch self { switch self {
case .respond: case .respond:
return "arrowshape.turn.up.left" return "arrowshape.turn.up.left"
case .boost: case .boost:
if (privateBoost) {
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "lock.rotation"
}
return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle" return viewModel.isReblogged ? "arrow.left.arrow.right.circle.fill" : "arrow.left.arrow.right.circle"
case .favorite: case .favorite:
return viewModel.isFavorited ? "star.fill" : "star" return viewModel.isFavorited ? "star.fill" : "star"
@ -77,7 +86,7 @@ struct StatusRowActionsView: View {
handleAction(action: action) handleAction(action: action)
} label: { } label: {
HStack(spacing: 2) { HStack(spacing: 2) {
Image(systemName: action.iconName(viewModel: viewModel)) Image(systemName: action.iconName(viewModel: viewModel, privateBoost: privateBoost()))
.foregroundColor(action.tintColor(viewModel: viewModel, theme: theme)) .foregroundColor(action.tintColor(viewModel: viewModel, theme: theme))
if let count = action.count(viewModel: viewModel, theme: theme), !viewModel.isRemote { if let count = action.count(viewModel: viewModel, theme: theme), !viewModel.isRemote {
Text("\(count)") Text("\(count)")
@ -87,7 +96,7 @@ struct StatusRowActionsView: View {
} }
.buttonStyle(.borderless) .buttonStyle(.borderless)
.disabled(action == .boost && .disabled(action == .boost &&
(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv)) (viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != currentAccount.account?.id))
Spacer() Spacer()
} }
} }

View file

@ -14,6 +14,20 @@ struct StatusRowContextMenu: View {
@ObservedObject var viewModel: StatusRowViewModel @ObservedObject var viewModel: StatusRowViewModel
var boostLabel: some View {
if self.viewModel.status.visibility == .priv && self.viewModel.status.account.id == self.account.account?.id {
if self.viewModel.isReblogged {
return Label("status.action.unboost", systemImage: "lock.rotation")
}
return Label("status.action.boost-to-followers", systemImage: "lock.rotation")
}
if self.viewModel.isReblogged {
return Label("status.action.unboost", systemImage: "arrow.left.arrow.right.circle")
}
return Label("status.action.boost", systemImage: "arrow.left.arrow.right.circle")
}
var body: some View { var body: some View {
if !viewModel.isRemote { if !viewModel.isRemote {
Button { Task { Button { Task {
@ -32,8 +46,9 @@ struct StatusRowContextMenu: View {
await viewModel.reblog() await viewModel.reblog()
} }
} } label: { } } label: {
Label(viewModel.isReblogged ? "status.action.unboost" : "status.action.boost", systemImage: "arrow.left.arrow.right.circle") boostLabel
} }
.disabled(viewModel.status.visibility == .direct || viewModel.status.visibility == .priv && viewModel.status.account.id != account.account?.id)
Button { Task { Button { Task {
if viewModel.isBookmarked { if viewModel.isBookmarked {
await viewModel.unbookmark() await viewModel.unbookmark()
@ -133,7 +148,7 @@ struct StatusRowContextMenu: View {
} }
} }
if account.account?.id == viewModel.status.account.id { if account.account?.id == viewModel.status.reblog?.account.id ?? viewModel.status.account.id {
Section("status.action.section.your-post") { Section("status.action.section.your-post") {
Button { Button {
Task { Task {