Skip to content

Commit

Permalink
Fix crash when conversations have no valid participants (mastodon#10078)
Browse files Browse the repository at this point in the history
* Never return empty participants for conversations

Fixes mastodon#10068

* Fix client-side crash when conversations have no participants
  • Loading branch information
ClearlyClaire authored and Gargron committed Feb 19, 2019
1 parent ce07ada commit 5d677d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/display_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class DisplayName extends React.PureComponent {
suffix = `+${others.size - 2}`;
}
} else {
if (others) {
if (others && others.size > 0) {
account = others.first();
} else {
account = this.props.account;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/components/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class Status extends ImmutablePureComponent {
);
}

if (otherAccounts) {
if (otherAccounts && otherAccounts.size > 0) {
statusAvatar = <AvatarComposite accounts={otherAccounts} size={48} />;
} else if (account === undefined || account === null) {
statusAvatar = <Avatar account={status.get('account')} size={48} />;
Expand Down
3 changes: 2 additions & 1 deletion app/models/account_conversation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def participant_accounts
if participant_account_ids.empty?
[account]
else
Account.where(id: participant_account_ids)
participants = Account.where(id: participant_account_ids)
participants.empty? ? [account] : participants
end
end

Expand Down

0 comments on commit 5d677d8

Please sign in to comment.