mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
enable search by username in message view #928
This commit is contained in:
parent
55c1410793
commit
06aeb126c2
|
@ -75,6 +75,10 @@ export class SearchResults extends React.Component<Props> {
|
|||
))}
|
||||
</div>
|
||||
) : null}
|
||||
{haveFriends
|
||||
? this.renderContacts(i18n('friendsHeader'), friends, true)
|
||||
: null}
|
||||
|
||||
{haveMessages ? (
|
||||
<div className="module-search-results__messages">
|
||||
{hideMessagesHeader ? null : (
|
||||
|
@ -95,4 +99,26 @@ export class SearchResults extends React.Component<Props> {
|
|||
</div>
|
||||
);
|
||||
}
|
||||
private renderContacts(
|
||||
header: string,
|
||||
items: Array<ConversationListItemPropsType>,
|
||||
friends?: boolean
|
||||
) {
|
||||
const { i18n, openConversation } = this.props;
|
||||
|
||||
return (
|
||||
<div className="module-search-results__contacts">
|
||||
<div className="module-search-results__contacts-header">{header}</div>
|
||||
{items.map(contact => (
|
||||
<ConversationListItem
|
||||
key={contact.phoneNumber}
|
||||
isFriend={friends}
|
||||
{...contact}
|
||||
onClick={openConversation}
|
||||
i18n={i18n}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,11 +132,16 @@ export class LeftPaneMessageSection extends React.Component<Props, any> {
|
|||
|
||||
public renderList(): JSX.Element | Array<JSX.Element | null> {
|
||||
const { openConversationInternal, searchResults } = this.props;
|
||||
const friends =
|
||||
(searchResults &&
|
||||
searchResults.contacts.filter(contact => contact.isFriend)) ||
|
||||
[];
|
||||
|
||||
if (searchResults) {
|
||||
return (
|
||||
<SearchResults
|
||||
{...searchResults}
|
||||
friends={friends}
|
||||
openConversation={openConversationInternal}
|
||||
i18n={window.i18n}
|
||||
/>
|
||||
|
|
|
@ -172,7 +172,7 @@ async function queryConversationsAndContacts(
|
|||
providedQuery: string,
|
||||
options: SearchOptions
|
||||
) {
|
||||
const { ourNumber, noteToSelf, isSecondaryDevice } = options;
|
||||
const { ourNumber, isSecondaryDevice } = options;
|
||||
const query = providedQuery.replace(/[+-.()]*/g, '');
|
||||
|
||||
const searchResults: Array<ConversationType> = await searchConversations(
|
||||
|
@ -193,8 +193,8 @@ async function queryConversationsAndContacts(
|
|||
);
|
||||
|
||||
// Split into two groups - active conversations and items just from address book
|
||||
let conversations: Array<string> = [];
|
||||
let contacts: Array<string> = [];
|
||||
const conversations: Array<string> = [];
|
||||
const contacts: Array<string> = [];
|
||||
const max = searchResults.length;
|
||||
for (let i = 0; i < max; i += 1) {
|
||||
const conversation = searchResults[i];
|
||||
|
@ -215,15 +215,6 @@ async function queryConversationsAndContacts(
|
|||
}
|
||||
}
|
||||
|
||||
// Inject synthetic Note to Self entry if query matches localized 'Note to Self'
|
||||
if (noteToSelf.indexOf(providedQuery.toLowerCase()) !== -1) {
|
||||
// ensure that we don't have duplicates in our results
|
||||
contacts = contacts.filter(id => id !== ourNumber);
|
||||
conversations = conversations.filter(id => id !== ourNumber);
|
||||
|
||||
contacts.unshift(ourNumber);
|
||||
}
|
||||
|
||||
return { conversations, contacts };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue