From 975fb2329299f6cb1946de9bf5a3b908aadffea7 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 17 Nov 2019 14:46:14 -0500 Subject: [PATCH] Possibly fix crash when reblogger account is cached --- Tusker/Views/Status/StatusTableViewCell.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Tusker/Views/Status/StatusTableViewCell.swift b/Tusker/Views/Status/StatusTableViewCell.swift index fcec8fe1..a62f5372 100644 --- a/Tusker/Views/Status/StatusTableViewCell.swift +++ b/Tusker/Views/Status/StatusTableViewCell.swift @@ -112,10 +112,7 @@ class StatusTableViewCell: UITableViewCell { rebloggerAccountUpdater = MastodonCache.accountSubject .filter { $0.id == self.rebloggerID } .receive(on: DispatchQueue.main) - .sink(receiveValue: { (_) in - // this method is responsible for setting the reblog label text - self.updateUIForPreferences() - }) + .sink(receiveValue: updateRebloggerLabel(reblogger:)) } func updateUI(statusID: String) { @@ -194,11 +191,15 @@ class StatusTableViewCell: UITableViewCell { avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView) if let rebloggerID = rebloggerID, let reblogger = MastodonCache.account(for: rebloggerID) { - reblogLabel.text = "Reblogged by \(reblogger.realDisplayName)" + updateRebloggerLabel(reblogger: reblogger) } displayNameLabel.text = account.realDisplayName } + func updateRebloggerLabel(reblogger: Account) { + reblogLabel.text = "Reblogged by \(reblogger.realDisplayName)" + } + func updateTimestamp() { guard let status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }