Possibly fix crash when reblogger account is cached

This commit is contained in:
Shadowfacts 2019-11-17 14:46:14 -05:00
parent 85812d774d
commit 975fb23292
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 6 additions and 5 deletions

View File

@ -112,10 +112,7 @@ class StatusTableViewCell: UITableViewCell {
rebloggerAccountUpdater = MastodonCache.accountSubject rebloggerAccountUpdater = MastodonCache.accountSubject
.filter { $0.id == self.rebloggerID } .filter { $0.id == self.rebloggerID }
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink(receiveValue: { (_) in .sink(receiveValue: updateRebloggerLabel(reblogger:))
// this method is responsible for setting the reblog label text
self.updateUIForPreferences()
})
} }
func updateUI(statusID: String) { func updateUI(statusID: String) {
@ -194,11 +191,15 @@ class StatusTableViewCell: UITableViewCell {
avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView) avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView)
if let rebloggerID = rebloggerID, if let rebloggerID = rebloggerID,
let reblogger = MastodonCache.account(for: rebloggerID) { let reblogger = MastodonCache.account(for: rebloggerID) {
reblogLabel.text = "Reblogged by \(reblogger.realDisplayName)" updateRebloggerLabel(reblogger: reblogger)
} }
displayNameLabel.text = account.realDisplayName displayNameLabel.text = account.realDisplayName
} }
func updateRebloggerLabel(reblogger: Account) {
reblogLabel.text = "Reblogged by \(reblogger.realDisplayName)"
}
func updateTimestamp() { func updateTimestamp() {
guard let status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") } guard let status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }