Add muting duration submenu (#662)

* Add muting duration submenu

* set japanese localizations
This commit is contained in:
Peter-Josef Meisch 2023-02-06 12:25:51 +01:00 committed by GitHub
parent b792d2cf16
commit c7f22d5022
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 186 additions and 11 deletions

View file

@ -23,6 +23,14 @@
"enum.avatar-position.top" = "Dalt";
"enum.avatar-shape.circle" = "Cercle";
"enum.avatar-shape.rounded" = "Arrodonida";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Tots";
"enum.status-actions-display.no-buttons" = "Sense botons";
"enum.status-actions-display.only-buttons" = "Només els botons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Oben";
"enum.avatar-shape.circle" = "Kreis";
"enum.avatar-shape.rounded" = "Abgerundet";
"enum.durations.infinite" = "unbegrenzt";
"enum.durations.fiveMinutes" = "5 Minuten";
"enum.durations.thirtyMinutes" = "30 Minuten";
"enum.durations.oneHour" = "1 Stunde";
"enum.durations.sixHours" = "6 Stunden";
"enum.durations.oneDay" = "1 Tag";
"enum.durations.threeDays" = "3 Tage";
"enum.durations.sevenDays" = "7 Tage";
"enum.status-actions-display.all" = "Alle";
"enum.status-actions-display.no-buttons" = "Keine Buttons";
"enum.status-actions-display.only-buttons" = "Nur Buttons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Top";
"enum.avatar-shape.circle" = "Circle";
"enum.avatar-shape.rounded" = "Rounded";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "All";
"enum.status-actions-display.no-buttons" = "No buttons";
"enum.status-actions-display.only-buttons" = "Only buttons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Top";
"enum.avatar-shape.circle" = "Circle";
"enum.avatar-shape.rounded" = "Rounded";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "All";
"enum.status-actions-display.no-buttons" = "No buttons";
"enum.status-actions-display.only-buttons" = "Only buttons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Arriba";
"enum.avatar-shape.circle" = "Círculo";
"enum.avatar-shape.rounded" = "Redondeado";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Todo";
"enum.status-actions-display.no-buttons" = "Sin botones";
"enum.status-actions-display.only-buttons" = "Sólo botones";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "En haut";
"enum.avatar-shape.circle" = "Rond";
"enum.avatar-shape.rounded" = "Arrondi";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Tout";
"enum.status-actions-display.no-buttons" = "Pas de boutons";
"enum.status-actions-display.only-buttons" = "Seulement les boutons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "In alto";
"enum.avatar-shape.circle" = "Cerchio";
"enum.avatar-shape.rounded" = "Arrotondata";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Tutti";
"enum.status-actions-display.no-buttons" = "Nessun bottone";
"enum.status-actions-display.only-buttons" = "Solo bottoni";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "トップ";
"enum.avatar-shape.circle" = "サークル";
"enum.avatar-shape.rounded" = "ラウンド";
"enum.durations.infinite" = "無期限";
"enum.durations.fiveMinutes" = "5分間";
"enum.durations.thirtyMinutes" = "30分間";
"enum.durations.oneHour" = "1時間";
"enum.durations.sixHours" = "6時間";
"enum.durations.oneDay" = "1日間";
"enum.durations.threeDays" = "3日間";
"enum.durations.sevenDays" = "7日間";
"enum.status-actions-display.all" = "すべて表示";
"enum.status-actions-display.no-buttons" = "ボタン無し";
"enum.status-actions-display.only-buttons" = "ボタンのみ";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "본문 위";
"enum.avatar-shape.circle" = "원";
"enum.avatar-shape.rounded" = "둥근 사각형";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "모두 표시";
"enum.status-actions-display.no-buttons" = "표시하지 않음";
"enum.status-actions-display.only-buttons" = "버튼만 표시";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Topp";
"enum.avatar-shape.circle" = "Sirkel";
"enum.avatar-shape.rounded" = "Avrundet";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Alle";
"enum.status-actions-display.no-buttons" = "Ingen knapper";
"enum.status-actions-display.only-buttons" = "Bare knapper";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Boven";
"enum.avatar-shape.circle" = "Cirkel";
"enum.avatar-shape.rounded" = "Afgerond";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Met tekst";
"enum.status-actions-display.no-buttons" = "Geen knoppen";
"enum.status-actions-display.only-buttons" = "Zonder tekst";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Na górze";
"enum.avatar-shape.circle" = "Okrągły";
"enum.avatar-shape.rounded" = "Zaokrąglony";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Wszystko";
"enum.status-actions-display.no-buttons" = "Bez przycisków";
"enum.status-actions-display.only-buttons" = "Tylko przyciski";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Topo";
"enum.avatar-shape.circle" = "Círculo";
"enum.avatar-shape.rounded" = "Arredondado";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Todos";
"enum.status-actions-display.no-buttons" = "Sem botões";
"enum.status-actions-display.only-buttons" = "Somente botões";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Üstte";
"enum.avatar-shape.circle" = "Çember";
"enum.avatar-shape.rounded" = "Yuvarlak";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "Hepsi";
"enum.status-actions-display.no-buttons" = "Butonsuz";
"enum.status-actions-display.only-buttons" = "Sadece Butonlar";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "顶部";
"enum.avatar-shape.circle" = "圆形";
"enum.avatar-shape.rounded" = "圆角";
"enum.durations.infinite" = "infinite";
"enum.durations.fiveMinutes" = "5 minutes";
"enum.durations.thirtyMinutes" = "30 minutes";
"enum.durations.oneHour" = "1 hour";
"enum.durations.sixHours" = "6 hours";
"enum.durations.oneDay" = "1 day";
"enum.durations.threeDays" = "3 days";
"enum.durations.sevenDays" = "7 days";
"enum.status-actions-display.all" = "图标和文本";
"enum.status-actions-display.no-buttons" = "仅文本";
"enum.status-actions-display.only-buttons" = "仅图标";

View file

@ -37,7 +37,7 @@ public struct AccountDetailView: View {
public init(account: Account) {
_viewModel = StateObject(wrappedValue: .init(account: account))
}
public var body: some View {
ScrollViewReader { proxy in
ScrollViewOffsetReader { offset in
@ -403,6 +403,7 @@ public struct AccountDetailView: View {
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
}
}
if viewModel.relationship?.muting == true {
Button {
Task {
@ -416,12 +417,16 @@ public struct AccountDetailView: View {
Label("account.action.unmute", systemImage: "speaker")
}
} else {
Button {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.mute(id: account.id))
} catch {
print("Error while muting: \(error.localizedDescription)")
Menu {
ForEach(MutingDurations.allCases, id: \.rawValue) { duration in
Button (duration.description) {
Task {
do {
viewModel.relationship = try await client.post(endpoint: Accounts.mute(id: account.id, json: MuteData(duration: duration.rawValue)))
} catch {
print("Error while muting: \(error.localizedDescription)")
}
}
}
}
} label: {

View file

@ -0,0 +1,33 @@
import SwiftUI
enum MutingDurations: Int, CaseIterable {
case infinite = 0
case fiveMinutes = 300
case thirtyMinutes = 1_800
case oneHour = 3_600
case sixHours = 21_600
case oneDay = 86_400
case threeDays = 259_200
case sevenDays = 604_800
public var description: LocalizedStringKey {
switch self {
case .infinite:
return "enum.durations.infinite"
case .fiveMinutes:
return "enum.durations.fiveMinutes"
case .thirtyMinutes:
return "enum.durations.thirtyMinutes"
case .oneHour:
return "enum.durations.oneHour"
case .sixHours:
return "enum.durations.sixHours"
case .oneDay:
return "enum.durations.oneDay"
case .threeDays:
return "enum.durations.threeDays"
case .sevenDays:
return "enum.durations.sevenDays"
}
}
}

View file

@ -32,9 +32,9 @@ public enum Accounts: Endpoint {
case preferences
case block(id: String)
case unblock(id: String)
case mute(id: String)
case mute(id: String, json: MuteData)
case unmute(id: String)
public func path() -> String {
switch self {
case let .accounts(id):
@ -75,13 +75,13 @@ public enum Accounts: Endpoint {
return "accounts/\(id)/block"
case let .unblock(id):
return "accounts/\(id)/unblock"
case let .mute(id):
case let .mute(id, _):
return "accounts/\(id)/mute"
case let .unmute(id):
return "accounts/\(id)/unmute"
}
}
public func queryItems() -> [URLQueryItem]? {
switch self {
case let .statuses(_, sinceId, tag, onlyMedia, excludeReplies, pinned):
@ -138,4 +138,21 @@ public enum Accounts: Endpoint {
return nil
}
}
public var jsonValue: Encodable? {
switch self {
case let .mute(_, json):
return json
default:
return nil
}
}
}
public struct MuteData: Encodable {
public let duration: Int
public init(duration: Int) {
self.duration = duration
}
}