Disable full-text search until we can go to arbitrary messages

This commit is contained in:
Scott Nonnenberg 2019-03-08 16:29:48 -08:00
parent b3ac1373fa
commit 031b64a476

View file

@ -2,9 +2,11 @@ import { omit, reject } from 'lodash';
import { normalize } from '../../types/PhoneNumber'; import { normalize } from '../../types/PhoneNumber';
import { trigger } from '../../shims/events'; import { trigger } from '../../shims/events';
import { getMessageModel } from '../../shims/Whisper'; // import { getMessageModel } from '../../shims/Whisper';
import { cleanSearchTerm } from '../../util/cleanSearchTerm'; // import { cleanSearchTerm } from '../../util/cleanSearchTerm';
import { searchConversations, searchMessages } from '../../../js/modules/data'; import {
searchConversations /*, searchMessages */,
} from '../../../js/modules/data';
import { makeLookup } from '../../util/makeLookup'; import { makeLookup } from '../../util/makeLookup';
import { import {
@ -97,9 +99,9 @@ async function doSearch(
): Promise<SearchResultsPayloadType> { ): Promise<SearchResultsPayloadType> {
const { regionCode, ourNumber, noteToSelf } = options; const { regionCode, ourNumber, noteToSelf } = options;
const [discussions, messages] = await Promise.all([ const [discussions /*, messages */] = await Promise.all([
queryConversationsAndContacts(query, { ourNumber, noteToSelf }), queryConversationsAndContacts(query, { ourNumber, noteToSelf }),
queryMessages(query), // queryMessages(query),
]); ]);
const { conversations, contacts } = discussions; const { conversations, contacts } = discussions;
@ -108,7 +110,7 @@ async function doSearch(
normalizedPhoneNumber: normalize(query, { regionCode }), normalizedPhoneNumber: normalize(query, { regionCode }),
conversations, conversations,
contacts, contacts,
messages: getMessageProps(messages) || [], messages: [], // getMessageProps(messages) || [],
}; };
} }
function clearSearch(): ClearSearchActionType { function clearSearch(): ClearSearchActionType {
@ -144,27 +146,27 @@ function startNewConversation(
// Helper functions for search // Helper functions for search
const getMessageProps = (messages: Array<MessageType>) => { // const getMessageProps = (messages: Array<MessageType>) => {
if (!messages || !messages.length) { // if (!messages || !messages.length) {
return []; // return [];
} // }
return messages.map(message => { // return messages.map(message => {
const model = getMessageModel(message); // const model = getMessageModel(message);
return model.propsForSearchResult; // return model.propsForSearchResult;
}); // });
}; // };
async function queryMessages(query: string) { // async function queryMessages(query: string) {
try { // try {
const normalized = cleanSearchTerm(query); // const normalized = cleanSearchTerm(query);
return searchMessages(normalized); // return searchMessages(normalized);
} catch (e) { // } catch (e) {
return []; // return [];
} // }
} // }
async function queryConversationsAndContacts( async function queryConversationsAndContacts(
providedQuery: string, providedQuery: string,