More readable code
This commit is contained in:
parent
ac35ec0c2e
commit
1010db0f4d
@ -92,17 +92,14 @@ struct AccountView: View {
|
|||||||
initialFollowing = isFollowing
|
initialFollowing = isFollowing
|
||||||
}
|
}
|
||||||
.refreshable {
|
.refreshable {
|
||||||
if let client = accountManager.getClient() {
|
if isCurrent {
|
||||||
if let ref: Account = try? await client.get(endpoint: Accounts.accounts(id: account.id)) {
|
guard let client = accountManager.getClient() else { return }
|
||||||
account = ref
|
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)
|
.background(Color.appBackground)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.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 {
|
func updateRelationship() async {
|
||||||
if let client = accountManager.getClient() {
|
if let client = accountManager.getClient() {
|
||||||
if let currentAccount: Account = try? await client.get(endpoint: Accounts.verifyCredentials) {
|
if let currentAccount: Account = try? await client.get(endpoint: Accounts.verifyCredentials) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user