@@ -67,14 +67,6 @@ type SearchDiscussionsResultsKickoffActionType = {
67
67
payload : Promise < SearchDiscussionsResultsPayloadType > ;
68
68
} ;
69
69
70
- type SearchMessagesResultsPendingActionType = {
71
- type : 'SEARCH_MESSAGES_RESULTS_PENDING' ;
72
- payload : SearchMessagesResultsPayloadType ;
73
- } ;
74
- type SearchDiscussionsResultsPendingActionType = {
75
- type : 'SEARCH_DISCUSSIONS_RESULTS_PENDING' ;
76
- payload : SearchDiscussionsResultsPayloadType ;
77
- } ;
78
70
type SearchMessagesResultsFulfilledActionType = {
79
71
type : 'SEARCH_MESSAGES_RESULTS_FULFILLED' ;
80
72
payload : SearchMessagesResultsPayloadType ;
@@ -108,8 +100,6 @@ type SearchInConversationActionType = {
108
100
export type SEARCH_TYPES =
109
101
| SearchMessagesResultsKickoffActionType
110
102
| SearchDiscussionsResultsKickoffActionType
111
- | SearchMessagesResultsPendingActionType
112
- | SearchDiscussionsResultsPendingActionType
113
103
| SearchMessagesResultsFulfilledActionType
114
104
| SearchDiscussionsResultsFulfilledActionType
115
105
| UpdateSearchTermActionType
@@ -327,9 +317,22 @@ export function reducer(
327
317
const { payload } = action ;
328
318
const { query } = payload ;
329
319
320
+ const hasQuery = Boolean ( query && query . length >= 2 ) ;
321
+ const isWithinConversation = Boolean ( state . searchConversationId ) ;
322
+
330
323
return {
331
324
...state ,
332
325
query,
326
+ messagesLoading : hasQuery ,
327
+ ...( hasQuery
328
+ ? {
329
+ messageIds : [ ] ,
330
+ messageLookup : { } ,
331
+ discussionsLoading : ! isWithinConversation ,
332
+ contacts : [ ] ,
333
+ conversations : [ ] ,
334
+ }
335
+ : { } ) ,
333
336
} ;
334
337
}
335
338
@@ -357,24 +360,6 @@ export function reducer(
357
360
} ;
358
361
}
359
362
360
- if ( action . type === 'SEARCH_MESSAGES_RESULTS_PENDING' ) {
361
- return {
362
- ...state ,
363
- messageIds : [ ] ,
364
- messageLookup : { } ,
365
- messagesLoading : true ,
366
- } ;
367
- }
368
-
369
- if ( action . type === 'SEARCH_DISCUSSIONS_RESULTS_PENDING' ) {
370
- return {
371
- ...state ,
372
- contacts : [ ] ,
373
- conversations : [ ] ,
374
- discussionsLoading : true ,
375
- } ;
376
- }
377
-
378
363
if ( action . type === 'SEARCH_MESSAGES_RESULTS_FULFILLED' ) {
379
364
const { payload } = action ;
380
365
const { messages, normalizedPhoneNumber, query } = payload ;
0 commit comments