From 5075d13902a74738ea5a353535c561661bad7bf4 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sat, 10 Aug 2024 19:40:33 +0530 Subject: [PATCH] Give visual feedback when interact with chat message feedback buttons - Use color to provide visual feedback when hover, click on feedback buttons - Use color to provide visual feedback when hover on speech, copy buttons click - Add cooldown period before being able to send feedback on that message again. Avoids inadvertent multiple consecutive clicks on feedback buttons --- .../components/chatMessage/chatMessage.tsx | 57 ++++++++++++++++--- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/src/interface/web/app/components/chatMessage/chatMessage.tsx b/src/interface/web/app/components/chatMessage/chatMessage.tsx index 9b2a2dcb..4e1e635d 100644 --- a/src/interface/web/app/components/chatMessage/chatMessage.tsx +++ b/src/interface/web/app/components/chatMessage/chatMessage.tsx @@ -142,21 +142,55 @@ function sendFeedback(uquery: string, kquery: string, sentiment: string) { } function FeedbackButtons({ uquery, kquery }: { uquery: string; kquery: string }) { + // Tri-state feedback state. + // Null = no feedback, true = positive feedback, false = negative feedback. + const [feedbackState, setFeedbackState] = useState(null); + + useEffect(() => { + if (feedbackState !== null) { + setTimeout(() => { + setFeedbackState(null); + }, 2000); + } + }, [feedbackState]); + return (
); @@ -547,7 +581,7 @@ export default function ChatMessage(props: ChatMessageProps) { > ) @@ -555,7 +589,7 @@ export default function ChatMessage(props: ChatMessageProps) { ))} @@ -568,9 +602,16 @@ export default function ChatMessage(props: ChatMessageProps) { }} > {copySuccess ? ( - + ) : ( - + )} {props.chatMessage.by === "khoj" &&