Fix crash when preferences are changed before own account is loaded

This commit is contained in:
Shadowfacts 2022-04-25 18:53:51 -04:00
parent 360f52d0cf
commit d2f1d78aa2
1 changed files with 4 additions and 4 deletions

View File

@ -182,12 +182,12 @@ class ProfileHeaderView: UIView {
@objc private func updateUIForPreferences() {
// todo: mastodonController should never be nil, but ProfileHeaderViews are getting leaked
guard let mastodonController = mastodonController else {
guard let mastodonController = mastodonController,
// nil if prefs changed before own account is loaded
let accountID = accountID,
let account = mastodonController.persistentContainer.account(for: accountID) else {
return
}
guard let account = mastodonController.persistentContainer.account(for: accountID) else {
fatalError("Missing cached account \(accountID!)")
}
avatarContainerView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarContainerView)
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)