Use fuse.js for regular contact search
This commit is contained in:
parent
085a698a73
commit
e1e1cfb892
5 changed files with 26 additions and 50 deletions
|
@ -207,7 +207,6 @@ const dataInterface: ClientInterface = {
|
|||
getAllConversationIds,
|
||||
getAllGroupsInvolvingUuid,
|
||||
|
||||
searchConversations,
|
||||
searchMessages,
|
||||
searchMessagesInConversation,
|
||||
|
||||
|
@ -1031,12 +1030,6 @@ async function getAllGroupsInvolvingUuid(uuid: UUIDStringType) {
|
|||
return channels.getAllGroupsInvolvingUuid(uuid);
|
||||
}
|
||||
|
||||
async function searchConversations(query: string) {
|
||||
const conversations = await channels.searchConversations(query);
|
||||
|
||||
return conversations;
|
||||
}
|
||||
|
||||
function handleSearchMessageJSON(
|
||||
messages: Array<ServerSearchResultMessageType>
|
||||
): Array<ClientSearchResultMessageType> {
|
||||
|
|
|
@ -363,10 +363,6 @@ export type DataInterface = {
|
|||
id: UUIDStringType
|
||||
) => Promise<Array<ConversationType>>;
|
||||
|
||||
searchConversations: (
|
||||
query: string,
|
||||
options?: { limit?: number }
|
||||
) => Promise<Array<ConversationType>>;
|
||||
// searchMessages is JSON on server, full message on Client
|
||||
// searchMessagesInConversation is JSON on server, full message on Client
|
||||
|
||||
|
|
|
@ -203,7 +203,6 @@ const dataInterface: ServerInterface = {
|
|||
getAllConversationIds,
|
||||
getAllGroupsInvolvingUuid,
|
||||
|
||||
searchConversations,
|
||||
searchMessages,
|
||||
searchMessagesInConversation,
|
||||
|
||||
|
@ -1526,33 +1525,6 @@ async function getAllGroupsInvolvingUuid(
|
|||
return rows.map(row => rowToConversation(row));
|
||||
}
|
||||
|
||||
async function searchConversations(
|
||||
query: string,
|
||||
{ limit }: { limit?: number } = {}
|
||||
): Promise<Array<ConversationType>> {
|
||||
const db = getInstance();
|
||||
const rows: ConversationRows = db
|
||||
.prepare<Query>(
|
||||
`
|
||||
SELECT json, profileLastFetchedAt
|
||||
FROM conversations WHERE
|
||||
(
|
||||
e164 LIKE $query OR
|
||||
name LIKE $query OR
|
||||
profileFullName LIKE $query
|
||||
)
|
||||
ORDER BY active_at DESC
|
||||
LIMIT $limit
|
||||
`
|
||||
)
|
||||
.all({
|
||||
query: `%${query}%`,
|
||||
limit: limit || 100,
|
||||
});
|
||||
|
||||
return rows.map(row => rowToConversation(row));
|
||||
}
|
||||
|
||||
async function searchMessages(
|
||||
query: string,
|
||||
params: { limit?: number; conversationId?: string } = {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue