Try to fix domain (IOS-192)

This commit is contained in:
Nathan Mattes 2023-12-14 14:07:58 +01:00
parent f373506aa3
commit 6cc069ec5b
2 changed files with 16 additions and 5 deletions

View File

@ -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
)
}

View File

@ -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
}
}
}