Skip to content

Commit

Permalink
Merge pull request #64 from jamakase/feature/front-basement
Browse files Browse the repository at this point in the history
loader works
  • Loading branch information
FanisNgv authored Sep 13, 2024
2 parents dec96eb + 89ff74b commit f836ea7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/src/app/(withSidebar)/conversations/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default function ConversationPage({
sender: "bot",
},
]);
const [loadingMessage, setLoadingMessage] = useState(false);

const config = useConfig();
const queryClient = useQueryClient();
Expand Down Expand Up @@ -65,7 +64,6 @@ export default function ConversationPage({
{
onSuccess: (data) => {
queryClient.invalidateQueries(["conversation", params.id]);
setLoadingMessage(false);
},
}
);
Expand All @@ -80,9 +78,13 @@ export default function ConversationPage({
if (!message.trim()) return;
sendMessageMutation.mutate(message);
setMessage("");
setLoadingMessage(true);
};

const isPendingRequest = currentConversation &&
currentConversation.length > 0 &&
currentConversation[currentConversation.length - 1].sender === "user" &&
currentConversation[currentConversation.length - 1].text !== null;

return (
<div className="min-h-full w-full relative overflow-hidden hide-scrollbar">
{/* {!isSidebarOpen && (
Expand Down Expand Up @@ -115,7 +117,7 @@ export default function ConversationPage({
messages={[
...initialMessages,
...(currentConversation || []),
...(loadingMessage
...(isPendingRequest
? [{ id: Date.now(), text: "Ответ вот-вот будет...", sender: "bot" }]
: []),
]}
Expand Down

0 comments on commit f836ea7

Please sign in to comment.