mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Allow to block/unblock and mute/unmute accounts (#120)
* Allow to block and unblock accounts * Mute and unmute accounts * Implement Localization (#80) * Implement localization * Fix some localization keys * Adapt to recent changes * Allow to block and unblock accounts * Mute and unmute accounts * Add localization Co-authored-by: Thomas <38211057+vollkorntomate@users.noreply.github.com> Co-authored-by: Thomas Ricouard <ricouard77@gmail.com>
This commit is contained in:
parent
980b9a5dd6
commit
1fb4eb2bef
3 changed files with 119 additions and 0 deletions
|
@ -122,6 +122,10 @@
|
||||||
"account.action.edit-info" = "Edit Info";
|
"account.action.edit-info" = "Edit Info";
|
||||||
"account.action.mention" = "Mention";
|
"account.action.mention" = "Mention";
|
||||||
"account.action.message" = "Message";
|
"account.action.message" = "Message";
|
||||||
|
"account.action.block" = "Block";
|
||||||
|
"account.action.unblock" = "Unblock";
|
||||||
|
"account.action.mute" = "Mute";
|
||||||
|
"account.action.unmute" = "Unmute";
|
||||||
"account.boosted-by" = "Boosted by";
|
"account.boosted-by" = "Boosted by";
|
||||||
"account.detail.about" = "About";
|
"account.detail.about" = "About";
|
||||||
"account.detail.familiar-followers" = "Also followed by";
|
"account.detail.familiar-followers" = "Also followed by";
|
||||||
|
|
|
@ -366,6 +366,109 @@ public struct AccountDetailView: View {
|
||||||
} label: {
|
} label: {
|
||||||
Label("account.action.message", systemImage: "tray.full")
|
Label("account.action.message", systemImage: "tray.full")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Divider()
|
||||||
|
|
||||||
|
if viewModel.relationship?.blocking == true {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
viewModel.relationship = try await client.post(endpoint: Accounts.unblock(id: account.id))
|
||||||
|
} catch {
|
||||||
|
print("Error while unblocking: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("account.action.unblock", systemImage: "person.crop.circle.badge.exclamationmark")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
viewModel.relationship = try await client.post(endpoint: Accounts.block(id: account.id))
|
||||||
|
} catch {
|
||||||
|
print("Error while blocking: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("account.action.block", systemImage: "person.crop.circle.badge.xmark")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if viewModel.relationship?.muting == true {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
viewModel.relationship = try await client.post(endpoint: Accounts.unmute(id: account.id))
|
||||||
|
} catch {
|
||||||
|
print("Error while unmuting: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
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)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("account.action.mute", systemImage: "speaker.slash")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if viewModel.relationship?.blocking == true {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
viewModel.relationship = try await client.post(endpoint: Accounts.unblock(id: account.id))
|
||||||
|
} catch {
|
||||||
|
print("Error while unblocking: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("Unblock", systemImage: "person.crop.circle.badge.exclamationmark")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
viewModel.relationship = try await client.post(endpoint: Accounts.block(id: account.id))
|
||||||
|
} catch {
|
||||||
|
print("Error while blocking: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("Block", systemImage: "person.crop.circle.badge.xmark")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if viewModel.relationship?.muting == true {
|
||||||
|
Button {
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
viewModel.relationship = try await client.post(endpoint: Accounts.unmute(id: account.id))
|
||||||
|
} catch {
|
||||||
|
print("Error while unmuting: \(error.localizedDescription)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("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)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} label: {
|
||||||
|
Label("Mute", systemImage: "speaker.slash")
|
||||||
|
}
|
||||||
|
}
|
||||||
Divider()
|
Divider()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,10 @@ public enum Accounts: Endpoint {
|
||||||
case following(id: String, maxId: String?)
|
case following(id: String, maxId: String?)
|
||||||
case lists(id: String)
|
case lists(id: String)
|
||||||
case preferences
|
case preferences
|
||||||
|
case block(id: String)
|
||||||
|
case unblock(id: String)
|
||||||
|
case mute(id: String)
|
||||||
|
case unmute(id: String)
|
||||||
|
|
||||||
public func path() -> String {
|
public func path() -> String {
|
||||||
switch self {
|
switch self {
|
||||||
|
@ -67,6 +71,14 @@ public enum Accounts: Endpoint {
|
||||||
return "accounts/\(id)/lists"
|
return "accounts/\(id)/lists"
|
||||||
case .preferences:
|
case .preferences:
|
||||||
return "preferences"
|
return "preferences"
|
||||||
|
case let .block(id):
|
||||||
|
return "accounts/\(id)/block"
|
||||||
|
case let .unblock(id):
|
||||||
|
return "accounts/\(id)/unblock"
|
||||||
|
case let .mute(id):
|
||||||
|
return "accounts/\(id)/mute"
|
||||||
|
case let .unmute(id):
|
||||||
|
return "accounts/\(id)/unmute"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue