Don't search conversations if searching within conversation
This commit is contained in:
parent
c9fd199b48
commit
e39c6e5321
3 changed files with 16 additions and 31 deletions
|
@ -1718,7 +1718,7 @@ async function searchConversations(query, { limit } = {}) {
|
|||
name LIKE $name OR
|
||||
profileName LIKE $profileName
|
||||
)
|
||||
ORDER BY id ASC
|
||||
ORDER BY active_at DESC
|
||||
LIMIT $limit`,
|
||||
{
|
||||
$id: `%${query}%`,
|
||||
|
|
|
@ -76,7 +76,7 @@ export class MainHeader extends React.Component<PropsType> {
|
|||
searchConversationId,
|
||||
} = this.props;
|
||||
|
||||
if (searchDiscussions) {
|
||||
if (searchDiscussions && !searchConversationId) {
|
||||
searchDiscussions(searchTerm, {
|
||||
noteToSelf: i18n('noteToSelf').toLowerCase(),
|
||||
ourNumber,
|
||||
|
@ -89,7 +89,7 @@ export class MainHeader extends React.Component<PropsType> {
|
|||
regionCode,
|
||||
});
|
||||
}
|
||||
}, 50);
|
||||
}, 200);
|
||||
|
||||
public updateSearch = (event: React.FormEvent<HTMLInputElement>) => {
|
||||
const {
|
||||
|
|
|
@ -67,14 +67,6 @@ type SearchDiscussionsResultsKickoffActionType = {
|
|||
payload: Promise<SearchDiscussionsResultsPayloadType>;
|
||||
};
|
||||
|
||||
type SearchMessagesResultsPendingActionType = {
|
||||
type: 'SEARCH_MESSAGES_RESULTS_PENDING';
|
||||
payload: SearchMessagesResultsPayloadType;
|
||||
};
|
||||
type SearchDiscussionsResultsPendingActionType = {
|
||||
type: 'SEARCH_DISCUSSIONS_RESULTS_PENDING';
|
||||
payload: SearchDiscussionsResultsPayloadType;
|
||||
};
|
||||
type SearchMessagesResultsFulfilledActionType = {
|
||||
type: 'SEARCH_MESSAGES_RESULTS_FULFILLED';
|
||||
payload: SearchMessagesResultsPayloadType;
|
||||
|
@ -108,8 +100,6 @@ type SearchInConversationActionType = {
|
|||
export type SEARCH_TYPES =
|
||||
| SearchMessagesResultsKickoffActionType
|
||||
| SearchDiscussionsResultsKickoffActionType
|
||||
| SearchMessagesResultsPendingActionType
|
||||
| SearchDiscussionsResultsPendingActionType
|
||||
| SearchMessagesResultsFulfilledActionType
|
||||
| SearchDiscussionsResultsFulfilledActionType
|
||||
| UpdateSearchTermActionType
|
||||
|
@ -327,9 +317,22 @@ export function reducer(
|
|||
const { payload } = action;
|
||||
const { query } = payload;
|
||||
|
||||
const hasQuery = Boolean(query && query.length >= 2);
|
||||
const isWithinConversation = Boolean(state.searchConversationId);
|
||||
|
||||
return {
|
||||
...state,
|
||||
query,
|
||||
messagesLoading: hasQuery,
|
||||
...(hasQuery
|
||||
? {
|
||||
messageIds: [],
|
||||
messageLookup: {},
|
||||
discussionsLoading: !isWithinConversation,
|
||||
contacts: [],
|
||||
conversations: [],
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -357,24 +360,6 @@ export function reducer(
|
|||
};
|
||||
}
|
||||
|
||||
if (action.type === 'SEARCH_MESSAGES_RESULTS_PENDING') {
|
||||
return {
|
||||
...state,
|
||||
messageIds: [],
|
||||
messageLookup: {},
|
||||
messagesLoading: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (action.type === 'SEARCH_DISCUSSIONS_RESULTS_PENDING') {
|
||||
return {
|
||||
...state,
|
||||
contacts: [],
|
||||
conversations: [],
|
||||
discussionsLoading: true,
|
||||
};
|
||||
}
|
||||
|
||||
if (action.type === 'SEARCH_MESSAGES_RESULTS_FULFILLED') {
|
||||
const { payload } = action;
|
||||
const { messages, normalizedPhoneNumber, query } = payload;
|
||||
|
|
Loading…
Add table
Reference in a new issue