forked from shadowfacts/Tusker
Fix race condition causing My Profile tab bar image to not be set
This commit is contained in:
parent
08045dd1e9
commit
5414f2329c
|
@ -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: AccountProtocol>(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
|
||||
|
|
Loading…
Reference in New Issue