diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index b43694483..f2fc6885a 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -298,9 +298,9 @@ extension ProfileViewController { // header #warning("TODO: Implement") let headerViewModel = profileHeaderViewController.viewModel! -// viewModel.$account -// .assign(to: \.account, on: headerViewModel) -// .store(in: &disposeBag) + viewModel.$account + .assign(to: \.account, on: headerViewModel) + .store(in: &disposeBag) viewModel.$isEditing .assign(to: \.isEditing, on: headerViewModel) .store(in: &disposeBag) @@ -378,11 +378,11 @@ extension ProfileViewController { profileHeaderViewController.profileHeaderView.viewModel.viewDidAppear ) .sink { [weak self] (user, _) in - guard let self else { return } + guard let self, let domain = user.domainFromAcct else { return } Task { _ = try await self.context.apiService.fetchUser( username: user.username, - domain: "user.domainFromAcct", + domain: domain, authenticationBox: self.authContext.mastodonAuthenticationBox ) } diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Account.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Account.swift index a358bcace..4de477896 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Account.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Account.swift @@ -178,4 +178,15 @@ extension Mastodon.Entity.Account { return !displayName.isEmpty ? displayName : username } + + public var domainFromAcct: String? { + if acct.contains("@") { + return domain + } else if let domain = acct.split(separator: "@").last { + return String(domain) + } else { + return nil + } + } + }