Fix a slew of bugs related to reblogs

Fixes #37
Fixes #38
Fixes #39
This commit is contained in:
Shadowfacts 2019-09-05 14:24:13 -04:00
parent ad0bbe0ab2
commit 1bc598691f
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 5 additions and 4 deletions

View File

@ -74,7 +74,7 @@ class StatusTableViewCell: UITableViewCell {
NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil)
statusUpdater = MastodonCache.statusSubject statusUpdater = MastodonCache.statusSubject
.filter { $0.id == self.statusID || $0.id == self.reblogStatusID } .filter { $0.id == self.statusID }
.receive(on: DispatchQueue.main) .receive(on: DispatchQueue.main)
.sink(receiveValue: updateStatusState(status:)) .sink(receiveValue: updateStatusState(status:))
@ -96,11 +96,12 @@ class StatusTableViewCell: UITableViewCell {
guard var status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID)") } guard var status = MastodonCache.status(for: statusID) else { fatalError("Missing cached status \(statusID)") }
self.statusID = statusID self.statusID = statusID
if let reblogID = status.reblog?.id, if let rebloggedStatusID = status.reblog?.id,
let reblog = MastodonCache.status(for: reblogID) { let rebloggedStatus = MastodonCache.status(for: rebloggedStatusID) {
reblogStatusID = statusID reblogStatusID = statusID
rebloggerID = status.account.id rebloggerID = status.account.id
status = reblog status = rebloggedStatus
self.statusID = rebloggedStatus.id
reblogLabel.isHidden = false reblogLabel.isHidden = false
} else { } else {
reblogStatusID = nil reblogStatusID = nil