Fix crash when requests race with own account

If the notifications/etc load first, and the table view cells are
created, mastodonController.account may still be nil
This commit is contained in:
Shadowfacts 2022-11-14 21:31:30 -05:00
parent 99a1c76cb1
commit ce7ce3ac92
3 changed files with 4 additions and 4 deletions

View File

@ -95,7 +95,7 @@ class StatusPollView: UIView {
guard let poll = poll else { return }
// poll.voted is nil if there is no user (e.g., public timeline), in which case the poll also cannot be voted upon
if (poll.voted ?? true) || poll.expired || status.account.id == mastodonController.account.id {
if (poll.voted ?? true) || poll.expired || status.account.id == mastodonController.account?.id {
canVote = false
} else {
canVote = true
@ -126,7 +126,7 @@ class StatusPollView: UIView {
if expired {
voteButton.disabledTitle = "Expired"
} else if poll.voted ?? false {
if status.account.id == mastodonController.account.id {
if status.account.id == mastodonController.account?.id {
voteButton.isHidden = true
} else {
voteButton.disabledTitle = "Voted"

View File

@ -170,7 +170,7 @@ class BaseStatusTableViewCell: UITableViewCell {
let reblogDisabled: Bool
if mastodonController.instanceFeatures.boostToOriginalAudience {
// Pleroma allows 'Boost to original audience' for your own private posts
reblogDisabled = status.visibility == .direct || (status.visibility == .private && status.account.id != mastodonController.account.id)
reblogDisabled = status.visibility == .direct || (status.visibility == .private && status.account.id != mastodonController.account?.id)
} else {
reblogDisabled = status.visibility == .private || status.visibility == .direct
}

View File

@ -131,7 +131,7 @@ extension StatusCollectionViewCell {
}
if status.visibility == .direct || status.visibility == .private {
if mastodonController.instanceFeatures.boostToOriginalAudience,
status.account.id == mastodonController.account.id {
status.account.id == mastodonController.account?.id {
return true
}
return false