Fix crash when updating timestamp of removed status

This commit is contained in:
Shadowfacts 2021-01-12 22:17:30 -05:00
parent 69c2faf0e1
commit d7aa3f1617
1 changed files with 3 additions and 2 deletions

View File

@ -123,8 +123,9 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
private func updateTimestamp() {
// if the mastodonController is nil (i.e. the delegate is nil), then the screen this cell was a part of has been deallocated
// so we bail out immediately, since there's nothing to update
guard let mastodonController = mastodonController else { return }
guard let status = mastodonController.persistentContainer.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
// if the status cannot be found, it may have already been discarded due to not being on screen, so we do nothing
guard let mastodonController = mastodonController,
let status = mastodonController.persistentContainer.status(for: statusID) else { return }
doUpdateTimestamp(status: status)
}