From 6aedb309050ebb98a61c455c5cfaf1d345435f1e Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 18 Jun 2020 15:28:45 -0700 Subject: [PATCH] getPropsForSearchResult: Harden to missing conversation --- js/models/messages.js | 14 ++++++++------ ts/components/MessageSearchResult.md | 17 +++++++++++++++++ ts/components/conversation/ContactName.tsx | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/js/models/messages.js b/js/models/messages.js index 16c13167b..cf3b021fb 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -199,13 +199,15 @@ fromContact.isMe = true; } - const conversation = this.getConversation(); - let to = this.findAndFormatContact(conversation.get('id')); - if (conversation.isMe()) { + const convo = this.getConversation(); + + let to = convo ? this.findAndFormatContact(convo.get('id')) : {}; + + if (convo && convo.isMe()) { to.isMe = true; } else if ( - sourceE164 === conversation.get('e164') || - sourceUuid === conversation.get('uuid') + (sourceE164 && convo && sourceE164 === convo.get('e164')) || + (sourceUuid && convo && sourceUuid === convo.get('uuid')) ) { to = { isMe: true, @@ -213,7 +215,7 @@ } return { - from: fromContact, + from: fromContact || {}, to, isSelected: this.isSelected, diff --git a/ts/components/MessageSearchResult.md b/ts/components/MessageSearchResult.md index 1ad50030e..3829ad705 100644 --- a/ts/components/MessageSearchResult.md +++ b/ts/components/MessageSearchResult.md @@ -230,3 +230,20 @@ /> ``` + +#### Empty + +```jsx + + console.log('onClick', result)} + i18n={util.i18n} + /> + +``` diff --git a/ts/components/conversation/ContactName.tsx b/ts/components/conversation/ContactName.tsx index 1a88c146c..2e82a7bb8 100644 --- a/ts/components/conversation/ContactName.tsx +++ b/ts/components/conversation/ContactName.tsx @@ -24,7 +24,7 @@ export class ContactName extends React.Component { return ( - + {shouldShowProfile ? ' ' : null} {profileElement}