Skip to content

Commit

Permalink
Use messageSearchQuery.keyword in MessageSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
HoonBaek committed Jan 14, 2025
1 parent ca1c274 commit 20b8d89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/modules/MessageSearch/context/MessageSearchProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, {
useRef,
useState,
useReducer,
useMemo,
} from 'react';
import { SendbirdError } from '@sendbird/chat';
import type { MessageSearchQuery } from '@sendbird/chat/message';
Expand Down Expand Up @@ -104,7 +105,10 @@ const MessageSearchProvider: React.FC<MessageSearchProviderProps> = (props: Mess
{ sdk, logger, messageSearchDispatcher },
);

const requestString = useSearchStringEffect({ searchString: searchString ?? '' }, { messageSearchDispatcher });
const _searchString = useMemo(() => {
return searchString ?? messageSearchQuery?.keyword ?? '';
}, [searchString, messageSearchQuery?.keyword]);
const requestString = useSearchStringEffect({ searchString: _searchString }, { messageSearchDispatcher });

useGetSearchMessages(
{ currentChannel, channelUrl, requestString, messageSearchQuery, onResultLoaded, retryCount },
Expand All @@ -122,7 +126,7 @@ const MessageSearchProvider: React.FC<MessageSearchProviderProps> = (props: Mess
return (
<MessageSearchContext.Provider value={{
channelUrl,
searchString,
searchString: _searchString,
requestString,
messageSearchQuery,
onResultLoaded,
Expand Down

0 comments on commit 20b8d89

Please sign in to comment.