Fix delay before My Profile sidebar item appears on launch

This commit is contained in:
Shadowfacts 2023-10-01 10:20:45 -04:00
parent 6a2de2be55
commit 46e1205327
2 changed files with 8 additions and 4 deletions

View File

@ -36,7 +36,7 @@ class MainSidebarMyProfileCollectionViewCell: UICollectionViewListCell {
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()
config.text = item.title
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)
guard let account = try? await mastodonController.getOwnAccount(),
let avatar = account.avatar else {

View File

@ -139,9 +139,7 @@ class MainSidebarViewController: UIViewController {
}
let myProfileCell = UICollectionView.CellRegistration<MainSidebarMyProfileCollectionViewCell, Item> { [unowned self] cell, indexPath, item in
Task {
await cell.updateUI(item: item, account: self.mastodonController.accountInfo!)
}
cell.updateUI(item: item, account: self.mastodonController.accountInfo!)
}
let outlineHeaderCell = UICollectionView.CellRegistration<UICollectionViewListCell, Item> { (cell, indexPath, item) in