diff --git a/Tusker/Screens/Profile/MyProfileViewController.swift b/Tusker/Screens/Profile/MyProfileViewController.swift index bf1945c55f..e384cddf4a 100644 --- a/Tusker/Screens/Profile/MyProfileViewController.swift +++ b/Tusker/Screens/Profile/MyProfileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import Pachyderm class MyProfileViewController: ProfileViewController { @@ -21,7 +22,7 @@ class MyProfileViewController: ProfileViewController { DispatchQueue.main.async { self.accountID = account.id - self.setAvatarTabBarImage() + self.setAvatarTabBarImage(account: account) } } } @@ -38,12 +39,7 @@ class MyProfileViewController: ProfileViewController { NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil) } - private func setAvatarTabBarImage() { - guard let id = mastodonController.account?.id, - let account = mastodonController.persistentContainer.account(for: id) else { - return - } - + private func setAvatarTabBarImage(account: Account) { _ = ImageCache.avatars.get(account.avatar, completion: { [weak self] (data) in guard let self = self, let data = data, let image = UIImage(data: data) else { return } DispatchQueue.main.async { @@ -61,7 +57,12 @@ class MyProfileViewController: ProfileViewController { } @objc private func preferencesChanged() { - setAvatarTabBarImage() + guard let id = mastodonController.account?.id, + let account = mastodonController.persistentContainer.account(for: id) else { + return + } + + setAvatarTabBarImage(account: account) } // MARK: - Interaction