mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-11 12:50:34 +08:00
retain non-selected followups
This commit is contained in:
@@ -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();
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user