From a750d1aa3414e32442d4a48c54828bfaa28e30c0 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 19 Feb 2019 20:00:41 +0100 Subject: [PATCH] Fix crash when conversations have no valid participants (#10078) * Never return empty participants for conversations Fixes #10068 * Fix client-side crash when conversations have no participants --- app/javascript/mastodon/components/display_name.js | 2 +- app/javascript/mastodon/components/status.js | 2 +- app/models/account_conversation.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/components/display_name.js b/app/javascript/mastodon/components/display_name.js index 32809778ae..6b9dd6f81b 100644 --- a/app/javascript/mastodon/components/display_name.js +++ b/app/javascript/mastodon/components/display_name.js @@ -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; diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 6f64e17c09..d420a2cb91 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -325,7 +325,7 @@ class Status extends ImmutablePureComponent { ); } - if (otherAccounts) { + if (otherAccounts && otherAccounts.size > 0) { statusAvatar = ; } else if (account === undefined || account === null) { statusAvatar = ; diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb index cc6b392798..0c03747e2a 100644 --- a/app/models/account_conversation.rb +++ b/app/models/account_conversation.rb @@ -30,7 +30,8 @@ class AccountConversation < ApplicationRecord 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