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-position.top" = "Dalt";
"enum.avatar-shape.circle" = "Cercle"; "enum.avatar-shape.circle" = "Cercle";
"enum.avatar-shape.rounded" = "Arrodonida"; "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.all" = "Tots";
"enum.status-actions-display.no-buttons" = "Sense botons"; "enum.status-actions-display.no-buttons" = "Sense botons";
"enum.status-actions-display.only-buttons" = "Només els botons"; "enum.status-actions-display.only-buttons" = "Només els botons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Oben"; "enum.avatar-position.top" = "Oben";
"enum.avatar-shape.circle" = "Kreis"; "enum.avatar-shape.circle" = "Kreis";
"enum.avatar-shape.rounded" = "Abgerundet"; "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.all" = "Alle";
"enum.status-actions-display.no-buttons" = "Keine Buttons"; "enum.status-actions-display.no-buttons" = "Keine Buttons";
"enum.status-actions-display.only-buttons" = "Nur Buttons"; "enum.status-actions-display.only-buttons" = "Nur Buttons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Top"; "enum.avatar-position.top" = "Top";
"enum.avatar-shape.circle" = "Circle"; "enum.avatar-shape.circle" = "Circle";
"enum.avatar-shape.rounded" = "Rounded"; "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.all" = "All";
"enum.status-actions-display.no-buttons" = "No buttons"; "enum.status-actions-display.no-buttons" = "No buttons";
"enum.status-actions-display.only-buttons" = "Only buttons"; "enum.status-actions-display.only-buttons" = "Only buttons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Top"; "enum.avatar-position.top" = "Top";
"enum.avatar-shape.circle" = "Circle"; "enum.avatar-shape.circle" = "Circle";
"enum.avatar-shape.rounded" = "Rounded"; "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.all" = "All";
"enum.status-actions-display.no-buttons" = "No buttons"; "enum.status-actions-display.no-buttons" = "No buttons";
"enum.status-actions-display.only-buttons" = "Only buttons"; "enum.status-actions-display.only-buttons" = "Only buttons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Arriba"; "enum.avatar-position.top" = "Arriba";
"enum.avatar-shape.circle" = "Círculo"; "enum.avatar-shape.circle" = "Círculo";
"enum.avatar-shape.rounded" = "Redondeado"; "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.all" = "Todo";
"enum.status-actions-display.no-buttons" = "Sin botones"; "enum.status-actions-display.no-buttons" = "Sin botones";
"enum.status-actions-display.only-buttons" = "Sólo botones"; "enum.status-actions-display.only-buttons" = "Sólo botones";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "En haut"; "enum.avatar-position.top" = "En haut";
"enum.avatar-shape.circle" = "Rond"; "enum.avatar-shape.circle" = "Rond";
"enum.avatar-shape.rounded" = "Arrondi"; "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.all" = "Tout";
"enum.status-actions-display.no-buttons" = "Pas de boutons"; "enum.status-actions-display.no-buttons" = "Pas de boutons";
"enum.status-actions-display.only-buttons" = "Seulement les boutons"; "enum.status-actions-display.only-buttons" = "Seulement les boutons";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "In alto"; "enum.avatar-position.top" = "In alto";
"enum.avatar-shape.circle" = "Cerchio"; "enum.avatar-shape.circle" = "Cerchio";
"enum.avatar-shape.rounded" = "Arrotondata"; "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.all" = "Tutti";
"enum.status-actions-display.no-buttons" = "Nessun bottone"; "enum.status-actions-display.no-buttons" = "Nessun bottone";
"enum.status-actions-display.only-buttons" = "Solo bottoni"; "enum.status-actions-display.only-buttons" = "Solo bottoni";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "トップ"; "enum.avatar-position.top" = "トップ";
"enum.avatar-shape.circle" = "サークル"; "enum.avatar-shape.circle" = "サークル";
"enum.avatar-shape.rounded" = "ラウンド"; "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.all" = "すべて表示";
"enum.status-actions-display.no-buttons" = "ボタン無し"; "enum.status-actions-display.no-buttons" = "ボタン無し";
"enum.status-actions-display.only-buttons" = "ボタンのみ"; "enum.status-actions-display.only-buttons" = "ボタンのみ";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "본문 위"; "enum.avatar-position.top" = "본문 위";
"enum.avatar-shape.circle" = "원"; "enum.avatar-shape.circle" = "원";
"enum.avatar-shape.rounded" = "둥근 사각형"; "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.all" = "모두 표시";
"enum.status-actions-display.no-buttons" = "표시하지 않음"; "enum.status-actions-display.no-buttons" = "표시하지 않음";
"enum.status-actions-display.only-buttons" = "버튼만 표시"; "enum.status-actions-display.only-buttons" = "버튼만 표시";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Topp"; "enum.avatar-position.top" = "Topp";
"enum.avatar-shape.circle" = "Sirkel"; "enum.avatar-shape.circle" = "Sirkel";
"enum.avatar-shape.rounded" = "Avrundet"; "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.all" = "Alle";
"enum.status-actions-display.no-buttons" = "Ingen knapper"; "enum.status-actions-display.no-buttons" = "Ingen knapper";
"enum.status-actions-display.only-buttons" = "Bare knapper"; "enum.status-actions-display.only-buttons" = "Bare knapper";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Boven"; "enum.avatar-position.top" = "Boven";
"enum.avatar-shape.circle" = "Cirkel"; "enum.avatar-shape.circle" = "Cirkel";
"enum.avatar-shape.rounded" = "Afgerond"; "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.all" = "Met tekst";
"enum.status-actions-display.no-buttons" = "Geen knoppen"; "enum.status-actions-display.no-buttons" = "Geen knoppen";
"enum.status-actions-display.only-buttons" = "Zonder tekst"; "enum.status-actions-display.only-buttons" = "Zonder tekst";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Na górze"; "enum.avatar-position.top" = "Na górze";
"enum.avatar-shape.circle" = "Okrągły"; "enum.avatar-shape.circle" = "Okrągły";
"enum.avatar-shape.rounded" = "Zaokrąglony"; "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.all" = "Wszystko";
"enum.status-actions-display.no-buttons" = "Bez przycisków"; "enum.status-actions-display.no-buttons" = "Bez przycisków";
"enum.status-actions-display.only-buttons" = "Tylko przyciski"; "enum.status-actions-display.only-buttons" = "Tylko przyciski";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Topo"; "enum.avatar-position.top" = "Topo";
"enum.avatar-shape.circle" = "Círculo"; "enum.avatar-shape.circle" = "Círculo";
"enum.avatar-shape.rounded" = "Arredondado"; "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.all" = "Todos";
"enum.status-actions-display.no-buttons" = "Sem botões"; "enum.status-actions-display.no-buttons" = "Sem botões";
"enum.status-actions-display.only-buttons" = "Somente botões"; "enum.status-actions-display.only-buttons" = "Somente botões";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "Üstte"; "enum.avatar-position.top" = "Üstte";
"enum.avatar-shape.circle" = "Çember"; "enum.avatar-shape.circle" = "Çember";
"enum.avatar-shape.rounded" = "Yuvarlak"; "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.all" = "Hepsi";
"enum.status-actions-display.no-buttons" = "Butonsuz"; "enum.status-actions-display.no-buttons" = "Butonsuz";
"enum.status-actions-display.only-buttons" = "Sadece Butonlar"; "enum.status-actions-display.only-buttons" = "Sadece Butonlar";

View file

@ -24,6 +24,14 @@
"enum.avatar-position.top" = "顶部"; "enum.avatar-position.top" = "顶部";
"enum.avatar-shape.circle" = "圆形"; "enum.avatar-shape.circle" = "圆形";
"enum.avatar-shape.rounded" = "圆角"; "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.all" = "图标和文本";
"enum.status-actions-display.no-buttons" = "仅文本"; "enum.status-actions-display.no-buttons" = "仅文本";
"enum.status-actions-display.only-buttons" = "仅图标"; "enum.status-actions-display.only-buttons" = "仅图标";

View file

@ -403,6 +403,7 @@ public struct AccountDetailView: View {
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark") Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
} }
} }
if viewModel.relationship?.muting == true { if viewModel.relationship?.muting == true {
Button { Button {
Task { Task {
@ -416,12 +417,16 @@ public struct AccountDetailView: View {
Label("account.action.unmute", systemImage: "speaker") Label("account.action.unmute", systemImage: "speaker")
} }
} else { } else {
Button { Menu {
Task { ForEach(MutingDurations.allCases, id: \.rawValue) { duration in
do { Button (duration.description) {
viewModel.relationship = try await client.post(endpoint: Accounts.mute(id: account.id)) Task {
} catch { do {
print("Error while muting: \(error.localizedDescription)") 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: { } 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,7 +32,7 @@ public enum Accounts: Endpoint {
case preferences case preferences
case block(id: String) case block(id: String)
case unblock(id: String) case unblock(id: String)
case mute(id: String) case mute(id: String, json: MuteData)
case unmute(id: String) case unmute(id: String)
public func path() -> String { public func path() -> String {
@ -75,7 +75,7 @@ public enum Accounts: Endpoint {
return "accounts/\(id)/block" return "accounts/\(id)/block"
case let .unblock(id): case let .unblock(id):
return "accounts/\(id)/unblock" return "accounts/\(id)/unblock"
case let .mute(id): case let .mute(id, _):
return "accounts/\(id)/mute" return "accounts/\(id)/mute"
case let .unmute(id): case let .unmute(id):
return "accounts/\(id)/unmute" return "accounts/\(id)/unmute"
@ -138,4 +138,21 @@ public enum Accounts: Endpoint {
return nil 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
}
} }