Load profile

This commit is contained in:
Nathan Mattes 2023-06-01 16:34:45 +02:00
parent 5513174696
commit 8df4729cdd
3 changed files with 28 additions and 3 deletions

View File

@ -32,5 +32,27 @@ final class MeProfileViewModel: ProfileViewModel {
}
.store(in: &disposeBag)
}
override func viewDidLoad() {
super.viewDidLoad()
Task {
do {
_ = try await context.apiService.authenticatedUserInfo(authenticationBox: authContext.mastodonAuthenticationBox).value
try await context.managedObjectContext.performChanges {
guard let me = self.authContext.mastodonAuthenticationBox.authentication.user(in: self.context.managedObjectContext) else {
assertionFailure()
return
}
self.me = me
}
} catch {
// do nothing?
}
}
}
}

View File

@ -287,6 +287,8 @@ extension ProfileViewController {
bindTitleView()
bindMoreBarButtonItem()
bindPager()
viewModel.viewDidLoad()
}
override func viewWillAppear(_ animated: Bool) {

View File

@ -176,9 +176,10 @@ class ProfileViewModel: NSObject {
.assign(to: &$isPagingEnabled)
}
}
extension ProfileViewModel {
func viewDidLoad() {
}
// fetch profile info before edit
func fetchEditProfileInfo() -> AnyPublisher<Mastodon.Response.Content<Mastodon.Entity.Account>, Error> {