More readable code
This commit is contained in:
parent
ac35ec0c2e
commit
1010db0f4d
|
@ -92,17 +92,14 @@ struct AccountView: View {
|
|||
initialFollowing = isFollowing
|
||||
}
|
||||
.refreshable {
|
||||
if let client = accountManager.getClient() {
|
||||
if let ref: Account = try? await client.get(endpoint: Accounts.accounts(id: account.id)) {
|
||||
account = ref
|
||||
if isCurrent {
|
||||
guard let client = accountManager.getClient() else { return }
|
||||
if let acc: Account = try? await client.get(endpoint: Accounts.verifyCredentials) {
|
||||
account = acc
|
||||
}
|
||||
}
|
||||
|
||||
await updateRelationship()
|
||||
loadingStatuses = true
|
||||
statuses = try? await client.get(endpoint: Accounts.statuses(id: account.id, sinceId: nil, tag: nil, onlyMedia: nil, excludeReplies: nil, pinned: nil))
|
||||
statusesPinned = try? await client.get(endpoint: Accounts.statuses(id: account.id, sinceId: nil, tag: nil, onlyMedia: nil, excludeReplies: nil, pinned: true))
|
||||
loadingStatuses = false
|
||||
}
|
||||
}
|
||||
await reloadUser()
|
||||
}
|
||||
.background(Color.appBackground)
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
|
@ -239,6 +236,21 @@ struct AccountView: View {
|
|||
}
|
||||
}
|
||||
|
||||
func reloadUser() async {
|
||||
if let client = accountManager.getClient() {
|
||||
let userAcc = accountManager.getAccount()
|
||||
if let ref: Account = try? await client.get(endpoint: Accounts.accounts(id: isCurrent && userAcc != nil ? userAcc!.id : account.id)) {
|
||||
account = ref
|
||||
|
||||
await updateRelationship()
|
||||
loadingStatuses = true
|
||||
statuses = try? await client.get(endpoint: Accounts.statuses(id: account.id, sinceId: nil, tag: nil, onlyMedia: nil, excludeReplies: nil, pinned: nil))
|
||||
statusesPinned = try? await client.get(endpoint: Accounts.statuses(id: account.id, sinceId: nil, tag: nil, onlyMedia: nil, excludeReplies: nil, pinned: true))
|
||||
loadingStatuses = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateRelationship() async {
|
||||
if let client = accountManager.getClient() {
|
||||
if let currentAccount: Account = try? await client.get(endpoint: Accounts.verifyCredentials) {
|
||||
|
|
Loading…
Reference in New Issue