]> cat aescling's git repositories - mastodon.git/commitdiff
Fix crash when conversations have no valid participants (#10078)
authorThibG <thib@sitedethib.com>
Tue, 19 Feb 2019 19:00:41 +0000 (20:00 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 19 Feb 2019 19:00:41 +0000 (20:00 +0100)
* Never return empty participants for conversations

Fixes #10068

* Fix client-side crash when conversations have no participants

app/javascript/mastodon/components/display_name.js
app/javascript/mastodon/components/status.js
app/models/account_conversation.rb

index 32809778ae7f273609534092f2c98b84630970c8..6b9dd6f81b1746a2974b9c101f297b68290f86d2 100644 (file)
@@ -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;
index 3e98d374b83a38602b6ef587380ef612d9259045..6270d3c92b0da2ea0839d607505f36e376580892 100644 (file)
@@ -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} />;
index cc6b39279866bceb1c01a7d8e25d2fb394bdd146..0c03747e2ae7b0793e8ffc16411d17d57290f765 100644 (file)
@@ -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