diff --git a/web/src/pages/index.tsx b/web/src/pages/index.tsx index fa51182..98ec3b3 100644 --- a/web/src/pages/index.tsx +++ b/web/src/pages/index.tsx @@ -244,7 +244,7 @@ const Home: NextPage = () => { query: string, query_source: "search" | "followups", disable: () => void, - enable: (followups: Followup[]) => void, + enable: (f_set: Followup[] | ((fs: Followup[]) => Followup[])) => void, ) => { // clear the query box, append to entries @@ -406,8 +406,6 @@ const Home: NextPage = () => { }, }); - console.log(res); - if (!res.ok) { enable([]); setLoadState({state: "idle"}); @@ -417,11 +415,11 @@ const Home: NextPage = () => { const data = await res.json(); - console.log(data); - setEntries([...new_entries, {role: "error", content: data.data.text}]); - enable([]); + // re-enable the searchbox, with the question that was just answered + // removed from the list of possible followups. + enable((fs: Followup[]) => fs.filter((f) => f.pageid !== query_id)); scroll30(); } diff --git a/web/src/searchbox.tsx b/web/src/searchbox.tsx index 1cc9e43..bbe2096 100644 --- a/web/src/searchbox.tsx +++ b/web/src/searchbox.tsx @@ -12,7 +12,7 @@ export const SearchBox: React.FC<{search: ( query: string, query_source: "search" | "followups", disable: () => void, - enable: (followups: Followup[]) => void, + enable: (f_set: Followup[] | ((fs: Followup[]) => Followup[])) => void, ) => void, }> = ({search}) => { @@ -25,9 +25,9 @@ export const SearchBox: React.FC<{search: ( // because everything is async, I can't just manually set state at the // point we do a search. Instead it needs to be passed into the search // method, for some reason. - const enable = (followups: Followup[]) => { + const enable = (f_set: Followup[] | ((fs: Followup[]) => Followup[])) => { setLoading(false); - setFollowups(followups); + setFollowups(f_set); }; const disable = () => { setLoading(true);