From 8e3c97f365768c5d6a355aec23f2abcdd1843df3 Mon Sep 17 00:00:00 2001 From: albin-karlsson <55614148+albin-karlsson@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:59:08 +0200 Subject: [PATCH 1/4] Add functionality for raising hand --- .../src/components/ConversationControls.jsx | 11 +++++- client/src/components/Council.jsx | 23 +++++++++++- client/src/components/HumanInput.jsx | 15 ++++++++ client/src/components/Output.jsx | 36 +++++++++++++++++-- client/src/components/TextOutput.jsx | 11 ++++-- 5 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 client/src/components/HumanInput.jsx diff --git a/client/src/components/ConversationControls.jsx b/client/src/components/ConversationControls.jsx index e7afbf9..1d157d3 100644 --- a/client/src/components/ConversationControls.jsx +++ b/client/src/components/ConversationControls.jsx @@ -1,10 +1,19 @@ import React from "react"; -function ConversationControls({ isPaused, onPauseResume, onSkipForward }) { +function ConversationControls({ + isPaused, + onPauseResume, + onSkipForward, + onRaiseHandOrNevermind, + isRaisedHand, +}) { return (
+
); } diff --git a/client/src/components/Council.jsx b/client/src/components/Council.jsx index 869d864..980dbbf 100644 --- a/client/src/components/Council.jsx +++ b/client/src/components/Council.jsx @@ -6,7 +6,9 @@ import Overlay from "./Overlay"; import CouncilOverlays from "./CouncilOverlays"; import Navbar from "./Navbar"; import Output from "./Output"; +import ConversationControls from "./ConversationControls"; import useWindowSize from "../hooks/useWindowSize"; +import HumanInput from "./HumanInput"; function Council({ options }) { const { foods, humanName, topic } = options; @@ -14,6 +16,9 @@ function Council({ options }) { const { width: screenWidth } = useWindowSize(); const [textMessages, setTextMessages] = useState([]); // State to store conversation updates const [audioMessages, setAudioMessages] = useState([]); // To store multiple ArrayBuffers + const [isReady, setIsReady] = useState(false); + const [isRaisedHand, setIsRaisedHand] = useState(false); + const socketRef = useRef(null); // Using useRef to persist socket instance const foodsContainerStyle = { @@ -62,6 +67,15 @@ function Council({ options }) { }; }, []); + function handleOnIsReady() { + setIsReady(true); + } + + function handleOnRaiseHandOrNevermind() { + console.log("Setting isRaisedHand..."); + setIsRaisedHand((prev) => !prev); + } + function displayResetWarning() { setActiveOverlay("reset"); } @@ -82,12 +96,19 @@ function Council({ options }) { className="text-container" style={{ justifyContent: "end" }} > - {/* Render the Output component regardless of the overlay */} + {isReady && ( + + )}
{foods.map((food, index) => ( diff --git a/client/src/components/HumanInput.jsx b/client/src/components/HumanInput.jsx new file mode 100644 index 0000000..4763592 --- /dev/null +++ b/client/src/components/HumanInput.jsx @@ -0,0 +1,15 @@ +import React from "react"; + +function HumanInput() { + return ( +
+