Skip to content

Commit

Permalink
Only fetch thread data if message state is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
StreetLamb committed Jun 1, 2024
1 parent 24259f9 commit 767f36e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/src/components/Teams/ChatTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ const ChatTeam = () => {
id: threadId!,
}),
{
enabled: !!threadId, // only runs the query if threadId is not null or undefined
/**
* Only run the query if messages state is empty and threadId is not null or undefined.
* Why only when empty? Thread data do not contain subgraphs history so its not ideal to overwrite while
* user might still be conversing.
*/
enabled: !!threadId && messages.length === 0,
onError: (err: ApiError) => {
const errDetail = err.body?.detail
showToast("Something went wrong.", `${errDetail}`, "error")
Expand Down

0 comments on commit 767f36e

Please sign in to comment.