Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: article suggestions refresh when user clicks settings #717 #740

Merged
merged 2 commits into from
Jun 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions app/components/Chatbot/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,20 @@ type FollowupsProps = {
}
const Followups = ({title, followups, onSelect, className}: FollowupsProps) => {
const {randomQuestions} = useOnSiteQuestions()
const items =
(followups?.length || 0) >= 3
? followups
: [
...(followups || []),
...randomQuestions().map(({title, pageid}) => ({text: title, pageid})),
].slice(0, 3)
const [items, setItems] = useState(followups)

useEffect(() => {
const initialItems =
(followups?.length || 0) >= 3
? followups
: [
...(followups || []),
...randomQuestions().map(({title, pageid}) => ({text: title, pageid})),
].slice(0, 3)

setItems(initialItems)
// eslint-disable-next-line
Copy link
Collaborator

@Aprillion Aprillion Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer if randomQuestions was a stable reference to a useCallback-ed function that wouldn't mess with useEffect deps => no need to disable eslint,, but not a blocker if that's not a trivial fix (I haven't checked myself at the moment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, but yeah it might be difficult because randomQuestions comes from a hook -> useOnSiteQuestions

}, [followups])
return (
<>
{title && <div className={'padding-bottom-24' + (className || '')}>{title}</div>}
Expand Down
Loading