Skip to content

Commit

Permalink
Check for search id before executing gda
Browse files Browse the repository at this point in the history
J=CLIP-1461
TEST=auto,manual

ran `npm run test` and tested manually on test-site to verified gda is executed as expected
  • Loading branch information
anguyen-yext2 committed Aug 7, 2024
1 parent a794ed5 commit ba4f8ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/search-ui-react",
"version": "1.7.0-beta.5",
"version": "1.7.0-beta.6",
"description": "A library of React Components for powering Yext Search integrations",
"author": "slapshot@yext.com",
"license": "BSD-3-Clause",
Expand Down
5 changes: 3 additions & 2 deletions src/components/GenerativeDirectAnswer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function GenerativeDirectAnswer({
const isUniversal = useSearchState(state => state.meta.searchType) === SearchTypeEnum.Universal;
const universalResults = useSearchState(state => state.universal);
const verticalResults = useSearchState(state => state.vertical);
const searchId = useSearchState(state => state.meta.uuid);

const searchResults: Result[] | undefined = React.useMemo(() => {
if (isUniversal) {
Expand All @@ -89,11 +90,11 @@ export function GenerativeDirectAnswer({
const isLoading = useSearchState(state => state.generativeDirectAnswer?.isLoading);

React.useEffect(() => {
if (!searchResults?.length) {
if (!searchResults?.length || !searchId) {
return;
}
executeGenerativeDirectAnswer(searchActions);
}, [searchResults]);
}, [searchResults, searchId]);

if (!searchResults?.length || isLoading || !gdaResponse || gdaResponse.resultStatus !== 'SUCCESS') {
return null;
Expand Down

0 comments on commit ba4f8ab

Please sign in to comment.