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 UIKit
|
||||||
|
import Pachyderm
|
||||||
|
|
||||||
class MyProfileViewController: ProfileViewController {
|
class MyProfileViewController: ProfileViewController {
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ class MyProfileViewController: ProfileViewController {
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.accountID = account.id
|
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)
|
NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setAvatarTabBarImage() {
|
private func setAvatarTabBarImage<Account: AccountProtocol>(account: Account) {
|
||||||
guard let id = mastodonController.account?.id,
|
|
||||||
let account = mastodonController.persistentContainer.account(for: id) else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
_ = ImageCache.avatars.get(account.avatar, completion: { [weak self] (data) in
|
_ = ImageCache.avatars.get(account.avatar, completion: { [weak self] (data) in
|
||||||
guard let self = self, let data = data, let image = UIImage(data: data) else { return }
|
guard let self = self, let data = data, let image = UIImage(data: data) else { return }
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
@ -61,7 +57,12 @@ class MyProfileViewController: ProfileViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func preferencesChanged() {
|
@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
|
// MARK: - Interaction
|
||||||
|
|
Loading…
Reference in New Issue