From c983670b9ed9ec46d021e49cbc09248ae527f058 Mon Sep 17 00:00:00 2001 From: Daniel D Orlando Date: Fri, 7 Apr 2023 06:02:28 -0700 Subject: [PATCH] Fix bug - when clicking on title in search results, was not switching to conversation --- client/src/components/Messages/Message.jsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/components/Messages/Message.jsx b/client/src/components/Messages/Message.jsx index 3c6c30129c..eec7f96bd0 100644 --- a/client/src/components/Messages/Message.jsx +++ b/client/src/components/Messages/Message.jsx @@ -8,7 +8,7 @@ import HoverButtons from './HoverButtons'; import SiblingSwitch from './SiblingSwitch'; import getIcon from '~/utils/getIcon'; import { useMessageHandler } from '~/utils/handleSubmit'; -import { getConversationById } from '~/data-provider'; +import { useGetConversationByIdQuery } from '~/data-provider'; import { cn } from '~/utils/'; import store from '~/store'; @@ -32,6 +32,7 @@ export default function Message({ const { ask, regenerate } = useMessageHandler(); const { switchToConversation } = store.useConversation(); const blinker = submitting && isSubmitting; + const getConversationQuery = useGetConversationByIdQuery(message.conversationId, { enabled: false }); useEffect(() => { if (blinker && !abortScroll) { @@ -97,11 +98,9 @@ export default function Message({ const clickSearchResult = async () => { if (!searchResult) return; - //we don't need react-query for this so we call the data service directly - const convoResponse = await getConversationById(message.conversationId); - const convo = convoResponse.data; - - switchToConversation(convo); + getConversationQuery.refetch(message.conversationId).then((response) => { + switchToConversation(response.data); + }); }; return (