Fix crash when updating timeline status cell timestamp

This commit is contained in:
Shadowfacts 2020-03-15 12:17:19 -04:00
parent 9af4118dfc
commit 64f41ea2b7
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 1 deletions

View File

@ -101,7 +101,10 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
}
func updateTimestamp() {
guard let mastodonController = mastodonController, let status = mastodonController.cache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
// 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.cache.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
timestampLabel.text = status.createdAt.timeAgoString()
timestampLabel.accessibilityLabel = TimelineStatusTableViewCell.relativeDateFormatter.localizedString(for: status.createdAt, relativeTo: Date())