@@ -46,39 +46,41 @@ function useGetSearchedMessages(
46
46
} ) ;
47
47
if ( sdk && channelUrl && sdk . createMessageSearchQuery && currentChannel ) {
48
48
if ( requestString ) {
49
- const inputSearchMessageQueryObject : MessageSearchQueryParams = {
50
- order : MessageSearchOrder . TIMESTAMP ,
51
- channelUrl,
52
- messageTimestampFrom : currentChannel . invitedAt ,
53
- keyword : requestString ,
54
- ...messageSearchQuery ,
55
- } ;
56
- const createdQuery = sdk . createMessageSearchQuery ( inputSearchMessageQueryObject ) ;
57
- createdQuery . next ( ) . then ( ( messages ) => {
58
- logger . info ( 'MessageSearch | useGetSearchedMessages: succeeded getting messages' , messages ) ;
59
- messageSearchDispatcher ( {
60
- type : messageActionTypes . GET_SEARCHED_MESSAGES ,
61
- payload : {
62
- messages,
63
- createdQuery,
64
- } ,
49
+ currentChannel . refresh ( ) . then ( ( channel ) => {
50
+ const inputSearchMessageQueryObject : MessageSearchQueryParams = {
51
+ order : MessageSearchOrder . TIMESTAMP ,
52
+ channelUrl,
53
+ messageTimestampFrom : channel . invitedAt ,
54
+ keyword : requestString ,
55
+ ...messageSearchQuery ,
56
+ } ;
57
+ const createdQuery = sdk . createMessageSearchQuery ( inputSearchMessageQueryObject ) ;
58
+ createdQuery . next ( ) . then ( ( messages ) => {
59
+ logger . info ( 'MessageSearch | useGetSearchedMessages: succeeded getting messages' , messages ) ;
60
+ messageSearchDispatcher ( {
61
+ type : messageActionTypes . GET_SEARCHED_MESSAGES ,
62
+ payload : {
63
+ messages,
64
+ createdQuery,
65
+ } ,
66
+ } ) ;
67
+ if ( onResultLoaded && typeof onResultLoaded === 'function' ) {
68
+ onResultLoaded ( messages , null ) ;
69
+ }
70
+ } ) . catch ( ( error ) => {
71
+ logger . warning ( 'MessageSearch | useGetSearchedMessages: getting failed' , error ) ;
72
+ messageSearchDispatcher ( {
73
+ type : messageActionTypes . SET_QUERY_INVALID ,
74
+ payload : null ,
75
+ } ) ;
76
+ if ( onResultLoaded && typeof onResultLoaded === 'function' ) {
77
+ onResultLoaded ( null , error ) ;
78
+ }
65
79
} ) ;
66
- if ( onResultLoaded && typeof onResultLoaded === 'function' ) {
67
- onResultLoaded ( messages , null ) ;
68
- }
69
- } ) . catch ( ( error ) => {
70
- logger . warning ( 'MessageSearch | useGetSearchedMessages: getting failed' , error ) ;
71
80
messageSearchDispatcher ( {
72
- type : messageActionTypes . SET_QUERY_INVALID ,
73
- payload : null ,
81
+ type : messageActionTypes . START_GETTING_SEARCHED_MESSAGES ,
82
+ payload : createdQuery ,
74
83
} ) ;
75
- if ( onResultLoaded && typeof onResultLoaded === 'function' ) {
76
- onResultLoaded ( null , error ) ;
77
- }
78
- } ) ;
79
- messageSearchDispatcher ( {
80
- type : messageActionTypes . START_GETTING_SEARCHED_MESSAGES ,
81
- payload : createdQuery ,
82
84
} ) ;
83
85
} else {
84
86
logger . info ( 'MessageSearch | useGetSeasrchedMessages: search string is empty' ) ;
0 commit comments