retain non-selected followups

This commit is contained in:
Fraser
2023-06-02 22:05:31 -04:00
parent 13c49f8600
commit 113d5ee81b
2 changed files with 7 additions and 9 deletions
+4 -6
View File
@@ -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();
}
+3 -3
View File
@@ -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);