From 7387e88c973f42fe462df54775eb9236c1325b2b Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 18 Apr 2019 10:37:23 +1000 Subject: [PATCH] Add showing friends in search. --- js/models/conversations.js | 1 + ts/state/ducks/conversations.ts | 1 + ts/state/selectors/conversations.ts | 9 ++++++++- ts/state/selectors/search.ts | 17 +++++++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index bc6ec1e5f..e6d7a475d 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -433,6 +433,7 @@ }, isOnline: this.isOnline(), hasNickname: !!this.getNickname(), + isFriend: this.isFriend(), onClick: () => this.trigger('select', this), onBlockContact: () => this.block(), diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index 2cbccfae5..21e1072f6 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -48,6 +48,7 @@ export type ConversationType = { unreadCount: number; isSelected: boolean; isTyping: boolean; + isFriend?: boolean; }; export type ConversationLookupType = { [key: string]: ConversationType; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 2d255f7da..ad817b382 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -96,16 +96,23 @@ export const _getLeftPaneLists = ( ): { conversations: Array; archivedConversations: Array; + contacts: Array; } => { const values = Object.values(lookup); const sorted = values.sort(comparator); const conversations: Array = []; const archivedConversations: Array = []; + const contacts: Array = []; const max = sorted.length; for (let i = 0; i < max; i += 1) { let conversation = sorted[i]; + + if (conversation.isFriend) { + contacts.push(conversation); + } + if (!conversation.activeAt) { continue; } @@ -124,7 +131,7 @@ export const _getLeftPaneLists = ( } } - return { conversations, archivedConversations }; + return { conversations, archivedConversations, contacts }; }; export const getLeftPaneLists = createSelector( diff --git a/ts/state/selectors/search.ts b/ts/state/selectors/search.ts index f638006b8..e6285416b 100644 --- a/ts/state/selectors/search.ts +++ b/ts/state/selectors/search.ts @@ -50,6 +50,8 @@ export const getSearchResults = createSelector( ) => { return { contacts: compact( + /* + LOKI: Unsure what signal does with this state.contacts.map(id => { const value = lookup[id]; @@ -62,6 +64,21 @@ export const getSearchResults = createSelector( return value; }) + */ + state.conversations.map(id => { + const value = lookup[id]; + + const friend = value && value.isFriend ? { ...value} : null; + + if (friend && id === selectedConversation) { + return { + ...friend, + isSelected: true, + }; + } + + return friend; + }) ), conversations: compact( state.conversations.map(id => {