forked from shadowfacts/Tusker
Fix delay before My Profile sidebar item appears on launch
This commit is contained in:
parent
6a2de2be55
commit
46e1205327
|
@ -36,7 +36,7 @@ class MainSidebarMyProfileCollectionViewCell: UICollectionViewListCell {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateUI(item: MainSidebarViewController.Item, account: UserAccountInfo) async {
|
func updateUI(item: MainSidebarViewController.Item, account: UserAccountInfo) {
|
||||||
var config = defaultContentConfiguration()
|
var config = defaultContentConfiguration()
|
||||||
config.text = item.title
|
config.text = item.title
|
||||||
config.image = UIImage(systemName: item.imageName!)
|
config.image = UIImage(systemName: item.imageName!)
|
||||||
|
@ -50,6 +50,12 @@ class MainSidebarMyProfileCollectionViewCell: UICollectionViewListCell {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Task {
|
||||||
|
await updateAvatar(account: account)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func updateAvatar(account: UserAccountInfo) async {
|
||||||
let mastodonController = MastodonController.getForAccount(account)
|
let mastodonController = MastodonController.getForAccount(account)
|
||||||
guard let account = try? await mastodonController.getOwnAccount(),
|
guard let account = try? await mastodonController.getOwnAccount(),
|
||||||
let avatar = account.avatar else {
|
let avatar = account.avatar else {
|
||||||
|
|
|
@ -139,9 +139,7 @@ class MainSidebarViewController: UIViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
let myProfileCell = UICollectionView.CellRegistration<MainSidebarMyProfileCollectionViewCell, Item> { [unowned self] cell, indexPath, item in
|
let myProfileCell = UICollectionView.CellRegistration<MainSidebarMyProfileCollectionViewCell, Item> { [unowned self] cell, indexPath, item in
|
||||||
Task {
|
cell.updateUI(item: item, account: self.mastodonController.accountInfo!)
|
||||||
await cell.updateUI(item: item, account: self.mastodonController.accountInfo!)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let outlineHeaderCell = UICollectionView.CellRegistration<UICollectionViewListCell, Item> { (cell, indexPath, item) in
|
let outlineHeaderCell = UICollectionView.CellRegistration<UICollectionViewListCell, Item> { (cell, indexPath, item) in
|
||||||
|
|
Loading…
Reference in New Issue