From d2f1d78aa26bb5fa609377b70cd6555d8decb6a1 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 25 Apr 2022 18:53:51 -0400 Subject: [PATCH] Fix crash when preferences are changed before own account is loaded --- Tusker/Views/Profile Header/ProfileHeaderView.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tusker/Views/Profile Header/ProfileHeaderView.swift b/Tusker/Views/Profile Header/ProfileHeaderView.swift index 15c790415b..dbda8d9d1d 100644 --- a/Tusker/Views/Profile Header/ProfileHeaderView.swift +++ b/Tusker/Views/Profile Header/ProfileHeaderView.swift @@ -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)