From f241440855809bc2ca037c6a9e0c7624ae4ff4cd Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Fri, 20 Dec 2019 14:58:21 +1100 Subject: [PATCH] conversation search: do not show user or friends results --- ts/components/LeftPane.tsx | 8 --- ts/components/SearchResults.tsx | 49 ------------------- .../session/LeftPaneMessageSection.tsx | 13 +---- ts/state/selectors/search.ts | 5 ++ 4 files changed, 6 insertions(+), 69 deletions(-) diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index 875bb60fb..49e1c5f85 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -17,12 +17,6 @@ interface Props { searchTerm: string; isSecondaryDevice: boolean; - // Action Creators - startNewConversation: ( - query: string, - options: { regionCode: string } - ) => void; - openConversationInternal: (id: string, messageId?: string) => void; updateSearchTerm: (searchTerm: string) => void; search: (query: string, options: SearchOptions) => void; @@ -60,7 +54,6 @@ export class LeftPane extends React.Component { private renderMessageSection() { const { - startNewConversation, openConversationInternal, conversations, searchResults, @@ -73,7 +66,6 @@ export class LeftPane extends React.Component { return ( ; friends: Array; @@ -27,21 +24,11 @@ export type PropsData = { type PropsHousekeeping = { i18n: LocalizerType; openConversation: (id: string, messageId?: string) => void; - startNewConversation: ( - query: string, - options: { regionCode: string } - ) => void; }; type Props = PropsData & PropsHousekeeping; export class SearchResults extends React.Component { - public handleStartNewConversation = () => { - const { regionCode, searchTerm, startNewConversation } = this.props; - mixpanel.track('New Conversation Started'); - startNewConversation(searchTerm, { regionCode }); - }; - public render() { const { conversations, @@ -73,13 +60,6 @@ export class SearchResults extends React.Component { {i18n('noSearchResults', [searchTerm])} ) : null} - {showStartNewConversation ? ( - - ) : null} {haveConversations ? (
@@ -95,12 +75,6 @@ export class SearchResults extends React.Component { ))}
) : null} - {haveFriends - ? this.renderContacts(i18n('friendsHeader'), friends, true) - : null} - {haveContacts - ? this.renderContacts(i18n('contactsHeader'), contacts) - : null} {haveMessages ? (
{hideMessagesHeader ? null : ( @@ -121,27 +95,4 @@ export class SearchResults extends React.Component {
); } - - private renderContacts( - header: string, - items: Array, - friends?: boolean - ) { - const { i18n, openConversation } = this.props; - - return ( -
-
{header}
- {items.map(contact => ( - - ))} -
- ); - } } diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index 10a9229c2..db69b5d93 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -27,14 +27,8 @@ export interface Props { conversations?: Array; - friends?: Array; searchResults?: SearchResultsProps; - // Action Creators - startNewConversation: ( - query: string, - options: { regionCode: string } - ) => void; updateSearchTerm: (searchTerm: string) => void; search: (query: string, options: SearchOptions) => void; openConversationInternal: (id: string, messageId?: string) => void; @@ -109,18 +103,13 @@ export class LeftPaneMessageSection extends React.Component { }; public renderList(): JSX.Element | Array { - const { - openConversationInternal, - startNewConversation, - searchResults, - } = this.props; + const { openConversationInternal, searchResults } = this.props; if (searchResults) { return ( ); diff --git a/ts/state/selectors/search.ts b/ts/state/selectors/search.ts index 22d8dbbe1..0598dab4b 100644 --- a/ts/state/selectors/search.ts +++ b/ts/state/selectors/search.ts @@ -67,6 +67,11 @@ export const getSearchResults = createSelector( state.conversations.map(id => { const value = lookup[id]; + // Don't return anything when activeAt is undefined (i.e. no current conversations with this user) + if (value.activeAt === undefined) { + return null; + } + if (value && id === selectedConversation) { return { ...value,