Skip to content

Commit

Permalink
fixed prevfactcheck auto searching
Browse files Browse the repository at this point in the history
  • Loading branch information
rosannamilner committed Aug 13, 2024
1 parent 8ddbca6 commit 4e32d11
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/NavItems/tools/SemanticSearch/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const SemanticSearch = () => {

const currentLang = useSelector((state) => state.language);

const text = useSelector((state) => state.assistant.urlText);
let text = useSelector((state) => state.assistant.urlText);

const { url } = useParams();

Expand Down Expand Up @@ -227,20 +227,23 @@ const SemanticSearch = () => {
if (url) {
const uri = url !== null ? decodeURIComponent(url) : undefined;
if (uri === "assistantText" && text) {
text = text.replaceAll("\n", " ");
setSearchString(text);
handleSubmit();
handleSubmit(text);
}
}
}, [url]);
}, [url, text]);

const handleSubmit = async () => {
const handleSubmit = async (text) => {
setIsLoading(true);
setHasUserSubmittedForm(true);
setErrorMessage("");

const urlText = searchString ? text : text;

let searchResults;
try {
searchResults = await getFactChecks(searchString, searchEngineMode);
searchResults = await getFactChecks(urlText, searchEngineMode);
} catch (e) {
// TODO: Handle Error
setErrorMessage(e.message);
Expand Down

0 comments on commit 4e32d11

Please sign in to comment.