From 94fb3f6c7e71f0ba436bf6e43200a50123108004 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Tue, 13 Feb 2024 11:35:25 +0100 Subject: [PATCH] Update account-screen when following/unfollowing/... (IOS-192) --- .../Scene/Profile/ProfileViewController.swift | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 881f44cae..ce9e968e8 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -863,12 +863,30 @@ extension ProfileViewController: ProfileHeaderViewControllerDelegate { account: viewModel.account ) - self.viewModel.isUpdating = false self.viewModel.relationship = newRelationship - // TODO: update account? - // TODO: update me? - } + let mastodonAuthenticationBox = self.viewModel.authContext.mastodonAuthenticationBox + let account = self.viewModel.account + if let domain = account.domain, let updatedAccount = try await self.viewModel.context.apiService.fetchUser( + username: self.viewModel.account.acct, + domain: domain, + authenticationBox: mastodonAuthenticationBox + ) { + self.viewModel.account = updatedAccount + } + + let me = self.viewModel.me + if let domain = me.domain, let updatedMe = try? await self.viewModel.context.apiService.fetchUser( + username: me.acct, + domain: domain, + authenticationBox: mastodonAuthenticationBox + ) { + FileManager.default.store(account: updatedMe, forUserID: self.viewModel.authContext.mastodonAuthenticationBox) + self.viewModel.me = updatedMe + } + + self.viewModel.isUpdating = false + } } }