Fix crash if status table view cell outlives VC

This commit is contained in:
Shadowfacts 2020-08-15 17:37:56 -04:00
parent 70bedf17a8
commit 60565f9625
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 2 deletions

View File

@ -102,7 +102,8 @@ class BaseStatusTableViewCell: UITableViewCell {
.filter { [unowned self] in $0 == self.statusID }
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
if let status = self.mastodonController.persistentContainer.status(for: $0) {
if let mastodonController = mastodonController,
let status = mastodonController.persistentContainer.status(for: $0) {
self.updateStatusState(status: status)
}
}
@ -113,7 +114,8 @@ class BaseStatusTableViewCell: UITableViewCell {
.filter { [unowned self] in $0 == self.accountID }
.receive(on: DispatchQueue.main)
.sink { [unowned self] in
if let account = self.mastodonController.persistentContainer.account(for: $0) {
if let mastodonController = mastodonController,
let account = mastodonController.persistentContainer.account(for: $0) {
self.updateUI(account: account)
}
}