diff --git a/Threaded/Views/AccountView.swift b/Threaded/Views/AccountView.swift index 1f5bcda..d1140ec 100644 --- a/Threaded/Views/AccountView.swift +++ b/Threaded/Views/AccountView.swift @@ -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 - - 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 + if isCurrent { + guard let client = accountManager.getClient() else { return } + if let acc: Account = try? await client.get(endpoint: Accounts.verifyCredentials) { + account = acc } } + + 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) {