From 07a1beae5e68dffee373948a9108427a64880388 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 2 Feb 2022 17:50:59 +1100 Subject: [PATCH] exclude ids from search entry --- app/sql.js | 7 ++++--- ts/hooks/useParamSelector.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/sql.js b/app/sql.js index 47a8ad6ad..2d9438c13 100644 --- a/app/sql.js +++ b/app/sql.js @@ -1837,15 +1837,13 @@ function searchConversations(query, { limit } = {}) { .prepare( `SELECT json FROM ${CONVERSATIONS_TABLE} WHERE ( - id LIKE $id OR name LIKE $name OR profileName LIKE $profileName ) AND active_at IS NOT NULL AND active_at > 0 - ORDER BY id ASC + ORDER BY active_at DESC LIMIT $limit` ) .all({ - id: `%${query}%`, name: `%${query}%`, profileName: `%${query}%`, limit: limit || 50, @@ -2322,6 +2320,9 @@ function getLastMessagesByConversation(conversationId, limit) { return map(rows, row => jsonToObject(row.json)); } +/** + * This is the oldest message so we cannot reuse getLastMessagesByConversation + */ function getOldestMessageInConversation(conversationId) { const rows = globalInstance .prepare( diff --git a/ts/hooks/useParamSelector.ts b/ts/hooks/useParamSelector.ts index 12a7d4254..e36f4a2c6 100644 --- a/ts/hooks/useParamSelector.ts +++ b/ts/hooks/useParamSelector.ts @@ -37,7 +37,7 @@ export function useConversationUsernameOrShorten(convoId?: string) { export function useConversationRealName(convoId?: string) { const convoProps = useConversationPropsById(convoId); - return convoProps?.name; + return convoProps?.isPrivate ? convoProps?.name : undefined; } /**