mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 02:01:02 +00:00
parent
09371f77c5
commit
f73bac9ae7
3 changed files with 17 additions and 3 deletions
|
@ -5,7 +5,6 @@ import Env
|
||||||
import Models
|
import Models
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Timeline
|
import Timeline
|
||||||
import Network
|
|
||||||
|
|
||||||
struct AccountSettingsView: View {
|
struct AccountSettingsView: View {
|
||||||
@Environment(\.dismiss) private var dismiss
|
@Environment(\.dismiss) private var dismiss
|
||||||
|
@ -68,8 +67,6 @@ struct AccountSettingsView: View {
|
||||||
Button(role: .destructive) {
|
Button(role: .destructive) {
|
||||||
if let token = appAccount.oauthToken {
|
if let token = appAccount.oauthToken {
|
||||||
Task {
|
Task {
|
||||||
let client = Client(server: appAccount.server, oauthToken: token)
|
|
||||||
await TimelineCache.shared.clearCache(for: client)
|
|
||||||
if let sub = pushNotifications.subscriptions.first(where: { $0.account.token == token }) {
|
if let sub = pushNotifications.subscriptions.first(where: { $0.account.token == token }) {
|
||||||
await sub.deleteSubscription()
|
await sub.deleteSubscription()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,13 @@ public struct ListEditView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.listRowBackground(theme.primaryBackgroundColor)
|
.listRowBackground(theme.primaryBackgroundColor)
|
||||||
|
}.onDelete { indexes in
|
||||||
|
if let index = indexes.first {
|
||||||
|
Task {
|
||||||
|
let account = viewModel.accounts[index]
|
||||||
|
await viewModel.delete(account: account)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,4 +25,14 @@ public class ListEditViewModel: ObservableObject {
|
||||||
isLoadingAccounts = false
|
isLoadingAccounts = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func delete(account: Account) async {
|
||||||
|
guard let client else { return }
|
||||||
|
do {
|
||||||
|
let response = try await client.delete(endpoint: Lists.updateAccounts(listId: list.id, accounts: [account.id]))
|
||||||
|
if response?.statusCode == 200 {
|
||||||
|
accounts.removeAll(where: { $0.id == account.id })
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue